/*****************************************************************
(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. MVC框架 - 高级示例

    在第一个MVC教程章中,我们学会了如何在MVC控制器和视图进行交互.在本教程中,我们将向前更进一步,学习如何使用模型创建高级应用程序来创建,编辑,删除用户,在我们的应用程序中查看列表. 下面是用来创建 ...

  2. 3. Android框架和工具之 xUtils(ViewUtils )

    1. ViewUtils 作用: 完全注解方式就可以进行UI绑定和事件绑定. 无需findViewById和setClickListener等. 2. UI绑定 和 事件绑定 (1)UI绑定 下面我們 ...

  3. 《MFC游戏开发》笔记十 游戏中的碰撞检测进阶:地图类型&障碍物判定

    本系列文章由七十一雾央编写,转载请注明出处. http://blog.csdn.net/u011371356/article/details/9394465 作者:七十一雾央 新浪微博:http:// ...

  4. [转]div内容底部对齐

    本文转自:http://blog.csdn.net/hellomy/article/details/5889833 <html> <head> <meta http-eq ...

  5. Kinect For Windows V2开发日志九:侦测并绘制人体骨架

    简介 在上一篇<侦测.追踪人体骨架>里,介绍了关节点的使用办法,这一篇记录将关节点与OpenCV结合的绘图方法. 代码 #include <iostream> #include ...

  6. 怒刷DP之 HDU 1069

    Monkey and Banana Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  7. Java中的堆和栈的区别

    当一个人开始学习Java或者其他编程语言的时候,会接触到堆和栈,由于一开始没有明确清晰的说明解释,很多人会产生很多疑问,什么是堆,什么是栈,堆和栈有什么区别?更糟糕的是,Java中存在栈这样一个后进先 ...

  8. [CAMCOCO][C#]我的系统架构.服务器端.(二)----DATA层

    这一层在园子里有很多很多的介绍了,这层写好之后老胡也没多研究,基本上就是参考的园子里大咖们的写法,具体的说明老胡也细说不了了,把接口和思路简单描述一下就好,如果有问题还是那句话,感谢您不吝赐教,老胡这 ...

  9. JavaScript之六种排序法

    1.冒泡排序循环的最大值从length递减每次循环只能排好最后一个,然后递减到第一个 function bubbleSort(){ var changedData = new Array(); var ...

  10. 【转载】分析商品日均销量(DMS)对促销商品选择的意义

    江苏省常州市信特超市有限公司副总经理高晓颖 随着中国零售业的进一步的开放,竞争日趋激烈,促销活动在日常经营中已经成为不可缺少的一部分,频繁的促销活动的开展,零售业经营管理者越来越觉得促销商品的选择难度 ...