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 ...
随机推荐
- [Android]天气App 3 网络数据的请求和Json解析
Android客户端开发,不仅仅是在Android端开发,还需要有相应的后台服务支持,否则的话,客户端的数据就只能放到本地自己做处理.我认为的原生态的App就是对应服务端的Client.他能像浏览 ...
- crawler4j:轻量级多线程网络爬虫实例
crawler4j是Java实现的开源网络爬虫.提供了简单易用的接口,可以在几分钟内创建一个多线程网络爬虫. 下面实例结合jsoup(中文版API),javacvs 爬取自如租房网(http://sh ...
- Storm累计求和中使用各种分组Grouping
Shuffle Grouping: 随机分组, 随机派发stream里面的tuple, 保证bolt中的每个任务接收到的tuple数目相同.(它能实现较好的负载均衡) Fields Grouping: ...
- hdu 4612 Warm up 桥缩点
4612Warm hdu up 题目:给出一个图,添加一条边之后,问能够在新图中得到的最少的桥的数量. 分析:我们可以双联通分量进行缩点,原图变成了一棵树.问题变成了:求树中添加一条边之后,使得不在圈 ...
- 自定义按钮设置BadgeNumber
TabbarButton.h @interface TabbarButton : UIButton @property (nonatomic, strong) UIButton *badgeValue ...
- AngularJS 学习笔记(1)
AngularJS是一款前端JS框架.AngularJS官网 http://angularjs.org [开发环境准备]: 1,下载AngularJS:JS and CSS in Solution 2 ...
- 跟我一起学习ASP.NET 4.5 MVC4.0(三)(转)
今天我们继续ASP.NET 4.5 MVC 4.0,前两天熟悉了MVC4.0在VS11和win8下的更新,以及MVC中的基础语法和几个关键字的使用.了解了这些就可以对MVC进一步认识,相信很多人都对M ...
- Android高级音频应用
说到音频应用,首先想到的就是音乐播放器.有些播放器可以播放流媒体,有些可以播放本地音乐文件.随着Android平台的演变,需要更多高级的音频API.好在谷歌新增了这方面的API,支持低延迟的音频流媒体 ...
- 【转】 memwatch使用说明书
memwatch使用说明书 1.memwatch是什么? memwatch是C语言的内存检测器.除了检测内存的功能外,它同样可以做其它的一些事情,而我们主要还是在于讲述它的基本功能.如果你真的想 ...
- webpShere中数据库集群url的设置
数据源配置的URL如下: jdbc:oracle:thin:@(DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 10 ...