How to enables AX email functionality without Outlook
/*****************************************************************
(C) Copyright DENTSPLY International. All rights reserved.
The use, disclosure, reproduction, modification, transfer, or
transmittal of this work for any purpose in any form or by any
means without written permission of DENTSPLY International is
strictly prohibited. Created Date: 10/Jun/2013
Created By: Jimmy Xie[Tectura]
Helpdesk Ticket#: KP000115
Description of Behavior: Enables AX email functionality without Outlook
Expected Input: Request to generate email
Expected Output: Email sent out of AX
******************************************************************/ void reportSendMail(PrintJobSettings p1)
{
//Start Declaration
//SysINetMail m = new SysINetMail(); // Commented out old AX code
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.Attachment attachment;
System.Net.Mail.AttachmentCollection attachementCollection;
System.Net.Mail.SmtpClient myMail;
str userMailAddress;
str receiverMailAddress;
str receiverCCMailAddress;
str mailBody;
str smtpServer;
str mail;
fileNameOpen fileNameForEmail;
FileIOPermission perm;
userinfo userInfo;
//end Declaration
str fileName = 'axaptareport';
SysEmailMessageTable sysEmailMessageTable;
; if (p1.format() == PrintFormat::ASCII)
{
fileNameForEmail = subStr(p1.fileName(),strLen(p1.fileName())-,-) + 'TXT'; // NL
}
//fileName = fileName + '.txt'; // Commented out this line else if (p1.format() == PrintFormat::RTF)
{
fileNameForEmail = subStr(p1.fileName(), strLen(p1.fileName())-, -) + 'RTF';
}
//fileName = fileName + '.rtf'; else if (p1.format() == PrintFormat::HTML)
{
fileNameForEmail = subStr(p1.fileName(), strLen(p1.fileName())-, -) + 'HTM';
}
//fileName = fileName + '.htm';
//else if (p1.format() == PrintFormat::PDF) // Performance Testing : commentign this line and replacing the line below.
else if (p1.format() == PrintFormat::PDF || p1.format() == PrintFormat::PDF_EMBED_FONTS)// Performance Testing :(replacing the above line) addign this line as it was present in the jsRemotecontroller project.. can be removedd later..
{
fileNameForEmail = subStr(p1.fileName(), strLen(p1.fileName())-, -) + 'PDF';
} //fileName = fileName + '.pdf';
//Start Logic
mail = subStr(fileNameforEmail, (strlen(fileNameforEmail)-), ); select firstonly name from userInfo where userInfo.id == SysuserInfo::find().Id; // to find the user name fileNameforEmail = winApi::getTempPath() + mail; // store attachment in a temp location perm = new FileIOPermission(fileNameforEmail, 'w'); if(!perm)
{
throw error("Cannot move attachment to temp location.");
} try
{
perm.assert();
}
catch
{
throw error("Cannot gain access to Temp location.");
} // find current users email address setup up in user //options
userMailAddress = SysUserInfo::find().Email; if(!info::validateEmail(userMailAddress))
{
throw error("Senders email is not valid");
} receiverMailAddress = p1.mailTo() + "," + p1.mailCc();
receiverMailAddress = strReplace(receiverMailAddress, ";" , ","); mailBody = SysEmailMessageTable::find("SysEmail", SysEmailTable::find("SysEmail").DefaultLanguage).Mail; // using the SMTP server ip //setup in email Parameters
smtpServer = SysEmaiLParameters::find(false).SMTPRelayServerName; try
{
mailMessage = new System.Net.Mail.MailMessage(userMailAddress, receiverMailAddress);
}
catch(Exception::Internal)
{
infolog.clear();
throw error("This Message was undeliverable due to the following reason:"
+"\n"
+"Your message was not delivered because a destination address was\n"
+"not found. Carefully check that it was spelled correctly and try\n"
+"sending it again if there were any mistakes.\n"
+"\n"
+"**When separating multiple email address please use either a comma or semicolon.**"
);
} mailmessage.set_Subject(p1.mailSubject());
mailmessage.set_Body(mailBody); mailmessage.set_IsBodyHtml(true); //move attachment file to Temp folder
winapi::moveFile(p1.fileName(), fileNameforEmail); attachementCollection = mailMessage.get_Attachments();
attachment = new System.Net.Mail.Attachment(fileNameforEmail);
attachementCollection.Add(attachment); myMail = new System.Net.Mail.SmtpClient(smtpServer);
mymail.Send(mailmessage); //Disopse COM objects
attachment.Dispose(); attachementCollection.Dispose();
mailMessage.Dispose(); //Delete the temp file
winApi::deleteFile(fileNameforEmail);
CodeAccessPermission::revertAssert();
//end
}
How to enables AX email functionality without Outlook的更多相关文章
- Global::validateEmail
/***************************************************************** (C) Copyright DENTSPLY Internatio ...
- Outlook HTML渲染引擎
OutLook始终不离不弃 是不是很讨厌为Email代码兼容Outlook? 太遗憾了!虽然光都有尽头,但Outlook始终存在. 为了应付Email的怪癖,我们花了很多时间测试,确保我们搞定了所有O ...
- Sending e-mail
E-mail functionality uses the Apache Commons Email library under the hood. You can use theplay.libs. ...
- [转]Outlook HTML渲染
转自:http://www.cnblogs.com/dolphinX/p/4081828.html 是不是很讨厌为Email代码兼容Outlook? 太遗憾了!虽然光都有尽头,但Outlook始终存在 ...
- [mutt] Configure mutt to receive email via IMAP and send via SMTP
“All mail clients suck. This one [mutt] just sucks less.” Michael Elkins, ca. 1995 Actually I have t ...
- Outlook Top of Information Store
Actually I got to thinking this might make a good blog post so I took a closer look - Try this: On t ...
- C4C和Outlook的集成
从C4C系统下载Outlook的Addin, 安装之后,会在Outlook里看见一个新的面板: 点击Log On登录: 如果需要的话,在Settings里设置proxy. 登录之后,即可立即在outl ...
- outlook使用inline style回复邮件
Reply with inline comments within the original message text When you reply to email messages in Outl ...
- 使用FluentEmail发送outlook邮件
一,邮箱账号相关设置 1,创建outLook邮箱. 2,进入邮箱设置->同步电子邮件->允许设备和应用使用pop 3,设置microsoft账号的应用程序密码->进入安全性页面-&g ...
随机推荐
- 转js contains 方法
function Jcontains(root, el) { if (root.compareDocumentPosition) return root === el || !!(root.compa ...
- uva 12100 Printer Queue 优先级队列模拟题 数组模拟队列
题目很简单,给一个队列以及文件的位置,然后一个一个检查,如果第一个是优先级最高的就打印,否则放到队列后面,求所要打印的文件打印需要花费多长时间. 这里我用数组模拟队列实现,考虑到最糟糕的情况,必须把数 ...
- SQL Server使用WITH AS递归查找
很多时候我们会在数据库表中存储树结构的数据,如菜单:一级菜单.二级菜单.三级菜单... 如果树结构层次比较多,如何能够在只知道某节点的情况下,找到此节点下的所有子级数据呢? 在.NET后台可以定义一个 ...
- 程序编码(机器级代码+汇编代码+C代码+反汇编)
[-1]相关声明 本文总结于csapp: 了解详情,或有兴趣,建议看原版书籍: [0]程序编码 GCC调用了一系列程序,将源代码转化成可执行代码的流程如下: (1)C预处理器扩展源代码,插入所有用#i ...
- 判断当前是否运行于Design Mode
在使用Visual Studio设计XAML时,设计器运行在[设计时]状态.VS在内部运行这些代码,帮你把界面的类真实效果展示出来.一般情况下也不会有什么问题,但是当代码中存在外部资源时,XAML可能 ...
- 转:android surface简单使用Demo
转: http://blog.csdn.net/listening_music/article/details/6860786 通过之前介绍的如何自定义View, 我们知道使用它可以做一些简单的动画效 ...
- 磁珠 磁环 双向二极管 TVS二极管
磁珠专用于抑制信号线.电源线上的高频噪声和尖峰干扰,还具有吸收静电脉冲的能力.磁珠是用来吸收超高频信号,像一些RF电路,PLL,振荡电路,含超高频存储器电路(DDR SDRAM,RAMBUS等)都需要 ...
- asp.net zip 压缩传输
在实际生产中,比如使用xml json 等传输大量数据的时候,有时候会出现等待时间过长,这里分享一个压缩传输的方法 首先到网上去下载一个 ICSharpCode.SharpZipLib.dll 的dl ...
- 常用字符串API
java.lang.string.1.0 1.char charAt(int index) 返回给定位置的代码单元. 2.int codePointAt(int index) 返回从给定位置开始或字 ...
- sql深入理解
我们做软件开发的,大部分人都离不开跟数据库打交道,特别是erp开发的,跟数据库打交道更是频繁,存储过程动不动就是上千行,如果数据量大,人员流动大,那么我们还能保证下一段时间系统还能流畅的运行吗?我们还 ...