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 ...
随机推荐
- KVO监听数组的变化
#import "ViewController.h" @interface ViewController () @property(nonatomic,strong)NSMutab ...
- 2dx解析cocosbuilder中使用layer时的缺陷
2dx解析cocosbuilder中使用layer时的缺陷 cocos2d-x 3.7 cocosbuilder中的layer通常会用到触摸属性: 但是在2dx解析布局文件的时候,却很多属性都没解析: ...
- hadoop2.6.0+eclipse配置
[0]安装前的声明 0.1) 所用节点2个 master : 192.168.119.105 hadoop5 slave : 192.168.119.101 hadoop1 (先用一个slave,跑成 ...
- Providers、Controller 、Service、DirectiveFactory
Providers 是唯一一种你可以传进 .config() 函数的 service.当你想要在 service 对象启用之前,先进行模块范围的配置,那就应该用 provider Controller ...
- android目录
2013-09-121.activity生命周期 activity生命周期2 widget http://blog.csdn.net/xiang_j2ee/article/details/727564 ...
- freeCodeCamp:Where art thou
写一个 function,它遍历一个对象数组(第一个参数)并返回一个包含相匹配的属性-值对(第二个参数)的所有对象的数组.如果返回的数组中包含 source 对象的属性-值对,那么此对象的每一个属性- ...
- 兼容性调试-- 在谷歌浏览器中,td 设置colspan的失效的问题
通过设置table width="100%"table-layout="fixed" 解决
- 关于GrideView Item点击后出现错乱重叠的情况
我在一个搜索页做了一个筛选信息的功能 大概思路如下:在根布局中用Include 引入一个筛选框(如图), 然后把边距设置为 android:layout_marginBottom="-250 ...
- Windows Kernel Way 1:Windows内核调试技术
掌握Windows内核调试技术是学习与研究Windows内核的基础,调试Windows内核的方式大致分为两种: (1)通过Windbg工具在Windows系统运行之初连接到Windows内核,连接成功 ...
- 读书笔记-UIView与控件
1.UIView 在Objective-C中,NSObject是所有类的“根”类.同样,在UIKit框架中,也存在一个如此神奇的类UIView.从继承关系上看,UIView是所有视图的根. 1.1.U ...