/*****************************************************************
(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. FVDI Commander products be replaced SVDI tools,really?

    You may have heard that some FVDI Commander products are being replaced by the new SVDI tools. This ...

  2. 重构19-Extract Factory Class(提取工厂类)

    在代码中,通常需要一些复杂的对象创建工作,以使这些对象达到一种可以使用的状态.通常情况下,这种创建不过是新建对象实例,并以我们需要的方式进行工作.但是,有时候这种创建对象的需求会极具增长,并且混淆了创 ...

  3. poj 2152 树形DP

    思路:这个没思路,看了陈启峰的论文写得. #include<map> #include<set> #include<cmath> #include<queue ...

  4. [转]移动App测试中的最佳做法

    Daniel Knott 用过各种不同编程语言和软件质量保证工具.他在软件开发和测试方面干了七年,自2010年起,他一直在德国汉堡的XING AG公司就职,几个项目里,比如XING调查和XING建议, ...

  5. Nginx服务器不支持PATH_INFO的问题及解决办法

    最近在写一个小程序,然后里面自己写了个URL的处理器,比如说访问index.php/article 那么就会自动加载进来article页面,访问index.php/home就会自动加载home页面. ...

  6. CSS图片翻转例子

                      dfdfdfdfdf <!DOCTYPE html> <html> <head> <meta charset=" ...

  7. css reset及部分layout样式

    /*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html { font-family: sans ...

  8. ASP.NET缓存全解析4:应用程序数据缓存 转自网络原文作者李天平

    System.Web.Caching 命名空间提供用于缓存服务器上常用数据的类.此命名空间包括 Cache 类,该类是一个字典,您可以在其中存储任意数据对象,如哈希表和数据集.它还为这些对象提供了失效 ...

  9. C#反射(转载)

    [转]C#反射   反射(Reflection)是.NET中的重要机制,通过放射,可以在运行时获得.NET中每一个类型(包括类.结构.委托.接口和枚举等)的成员,包括方法.属性.事件,以及构造函数等. ...

  10. 四步完成ajax的使用

    什么是ajax? ajax(异步javascript xml) 能够刷新局部网页数据而不是重新加载整个网页. 如何使用ajax? 第一步,创建xmlhttprequest对象,var xmlhttp ...