/*****************************************************************
(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的更多相关文章

  1. Global::validateEmail

    /***************************************************************** (C) Copyright DENTSPLY Internatio ...

  2. Outlook HTML渲染引擎

    OutLook始终不离不弃 是不是很讨厌为Email代码兼容Outlook? 太遗憾了!虽然光都有尽头,但Outlook始终存在. 为了应付Email的怪癖,我们花了很多时间测试,确保我们搞定了所有O ...

  3. Sending e-mail

    E-mail functionality uses the Apache Commons Email library under the hood. You can use theplay.libs. ...

  4. [转]Outlook HTML渲染

    转自:http://www.cnblogs.com/dolphinX/p/4081828.html 是不是很讨厌为Email代码兼容Outlook? 太遗憾了!虽然光都有尽头,但Outlook始终存在 ...

  5. [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 ...

  6. 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 ...

  7. C4C和Outlook的集成

    从C4C系统下载Outlook的Addin, 安装之后,会在Outlook里看见一个新的面板: 点击Log On登录: 如果需要的话,在Settings里设置proxy. 登录之后,即可立即在outl ...

  8. outlook使用inline style回复邮件

    Reply with inline comments within the original message text When you reply to email messages in Outl ...

  9. 使用FluentEmail发送outlook邮件

    一,邮箱账号相关设置 1,创建outLook邮箱. 2,进入邮箱设置->同步电子邮件->允许设备和应用使用pop 3,设置microsoft账号的应用程序密码->进入安全性页面-&g ...

随机推荐

  1. CGFloat、CGPoint、CGSize和CGRect

    CGFloat:是表示浮点数类型. CGPoint:表示二维坐标的点.通过x和y坐标定义.点表示位置值. CGSIZE:表示矩形的宽度和高度.通过宽度和高度来定义. CGRect: 表示矩形的位置和大 ...

  2. 如何导入hadoop源码到eclipse

    需要进一步学习hadoop.需要看看内部源码实现,因此需要将hadoop源码导入都eclipse中. 简单总结一下,具体步骤如下: 首先确保已经安装了git.maven3.protobuf2.5.如果 ...

  3. 【递归】数字三角形 简单dp

    [递归]数字三角形 题目描述 对于大多数人来说,“我们是这么的正常,因此也就这么的平庸.”而天才总是与众不同的,所以当邪狼问修罗王:“老大,你蹲在那儿一动不动看了有半个小时了,蚂蚁有那么好看吗?” 修 ...

  4. bootstrap daterangepicker 添加阴历及节假日

    所有的新增都用 'myAdd start'和'myAdd end'标注,所有的修改都用'myChange start'和'myChange end'标注. 借用了 1900-2100区间内的公历.农历 ...

  5. Camera 幻灯片播放

    Camera 幻灯片播放与轮播有些类似,不同的是在camera 幻灯片播放时有很多很炫很酷的播放效果 : 简单的介绍Camera 插件的使用方式: 1.引入js: <script src=&qu ...

  6. asp.net实现通用水晶报表

    此片博文是在你有一定水晶报表基础的前提下参阅的:如果对于水晶报表的基础知识比较薄弱建议先去了解下水晶报表: 因为项目需要,研究了下水晶报表.说实在,这个组件很强大,但是用起来也很麻烦.刚开始使用遇到了 ...

  7. android app性能优化大汇总(google官方Android性能优化典范 - 第1季)

    大多数用户感知到的卡顿等性能问题的最主要根源都是因为渲染性能.从设计师的角度,他们希望App能够有更多的动画,图片等时尚元素来实现流畅的用户体验.但是Android系统很有可能无法及时完成那些复杂的界 ...

  8. CSS之隐藏元素

    1.opacity=0,该元素隐藏起来了,但不会改变页面布局,并且,如果该元素已经绑定一些事件,如click事件,那么点击该区域,也能触发点击事件的2.visibility=hidden,该元素隐藏起 ...

  9. CSS之Generator

    这个工具可以,收藏一下.CSS Generator

  10. WPF button 如何区分click和doubleclick

    WPF button 同时处理两个事件时候会先触发click事件,触发doubleclick事件  ,那如何区分呢,可以这样设置: private static DispatcherTimer myC ...