1. /*****************************************************************
  2. (C) Copyright DENTSPLY International. All rights reserved.
  3. The use, disclosure, reproduction, modification, transfer, or
  4. transmittal of this work for any purpose in any form or by any
  5. means without written permission of DENTSPLY International is
  6. strictly prohibited.
  7.  
  8. Created Date: 10/Jun/2013
  9. Created By: Jimmy Xie[Tectura]
  10. Helpdesk Ticket#: KP000115
  11. Description of Behavior: Enables AX email functionality without Outlook
  12. Expected Input: Request to generate email
  13. Expected Output: Email sent out of AX
  14. ******************************************************************/
  15.  
  16. void reportSendMail(PrintJobSettings p1)
  17. {
  18. //Start Declaration
  19. //SysINetMail m = new SysINetMail(); // Commented out old AX code
  20. System.Net.Mail.MailMessage mailMessage;
  21. System.Net.Mail.Attachment attachment;
  22. System.Net.Mail.AttachmentCollection attachementCollection;
  23. System.Net.Mail.SmtpClient myMail;
  24. str userMailAddress;
  25. str receiverMailAddress;
  26. str receiverCCMailAddress;
  27. str mailBody;
  28. str smtpServer;
  29. str mail;
  30. fileNameOpen fileNameForEmail;
  31. FileIOPermission perm;
  32. userinfo userInfo;
  33. //end Declaration
  34. str fileName = 'axaptareport';
  35. SysEmailMessageTable sysEmailMessageTable;
  36. ;
  37.  
  38. if (p1.format() == PrintFormat::ASCII)
  39. {
  40. fileNameForEmail = subStr(p1.fileName(),strLen(p1.fileName())-,-) + 'TXT'; // NL
  41. }
  42. //fileName = fileName + '.txt'; // Commented out this line
  43.  
  44. else if (p1.format() == PrintFormat::RTF)
  45. {
  46. fileNameForEmail = subStr(p1.fileName(), strLen(p1.fileName())-, -) + 'RTF';
  47. }
  48. //fileName = fileName + '.rtf';
  49.  
  50. else if (p1.format() == PrintFormat::HTML)
  51. {
  52. fileNameForEmail = subStr(p1.fileName(), strLen(p1.fileName())-, -) + 'HTM';
  53. }
  54. //fileName = fileName + '.htm';
  55. //else if (p1.format() == PrintFormat::PDF) // Performance Testing : commentign this line and replacing the line below.
  56. 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..
  57. {
  58. fileNameForEmail = subStr(p1.fileName(), strLen(p1.fileName())-, -) + 'PDF';
  59. }
  60.  
  61. //fileName = fileName + '.pdf';
  62. //Start Logic
  63. mail = subStr(fileNameforEmail, (strlen(fileNameforEmail)-), );
  64.  
  65. select firstonly name from userInfo where userInfo.id == SysuserInfo::find().Id; // to find the user name
  66.  
  67. fileNameforEmail = winApi::getTempPath() + mail; // store attachment in a temp location
  68.  
  69. perm = new FileIOPermission(fileNameforEmail, 'w');
  70.  
  71. if(!perm)
  72. {
  73. throw error("Cannot move attachment to temp location.");
  74. }
  75.  
  76. try
  77. {
  78. perm.assert();
  79. }
  80. catch
  81. {
  82. throw error("Cannot gain access to Temp location.");
  83. }
  84.  
  85. // find current users email address setup up in user //options
  86. userMailAddress = SysUserInfo::find().Email;
  87.  
  88. if(!info::validateEmail(userMailAddress))
  89. {
  90. throw error("Senders email is not valid");
  91. }
  92.  
  93. receiverMailAddress = p1.mailTo() + "," + p1.mailCc();
  94. receiverMailAddress = strReplace(receiverMailAddress, ";" , ",");
  95.  
  96. mailBody = SysEmailMessageTable::find("SysEmail", SysEmailTable::find("SysEmail").DefaultLanguage).Mail;
  97.  
  98. // using the SMTP server ip //setup in email Parameters
  99. smtpServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
  100.  
  101. try
  102. {
  103. mailMessage = new System.Net.Mail.MailMessage(userMailAddress, receiverMailAddress);
  104. }
  105. catch(Exception::Internal)
  106. {
  107. infolog.clear();
  108. throw error("This Message was undeliverable due to the following reason:"
  109. +"\n"
  110. +"Your message was not delivered because a destination address was\n"
  111. +"not found. Carefully check that it was spelled correctly and try\n"
  112. +"sending it again if there were any mistakes.\n"
  113. +"\n"
  114. +"**When separating multiple email address please use either a comma or semicolon.**"
  115. );
  116. }
  117.  
  118. mailmessage.set_Subject(p1.mailSubject());
  119. mailmessage.set_Body(mailBody);
  120.  
  121. mailmessage.set_IsBodyHtml(true);
  122.  
  123. //move attachment file to Temp folder
  124. winapi::moveFile(p1.fileName(), fileNameforEmail);
  125.  
  126. attachementCollection = mailMessage.get_Attachments();
  127. attachment = new System.Net.Mail.Attachment(fileNameforEmail);
  128. attachementCollection.Add(attachment);
  129.  
  130. myMail = new System.Net.Mail.SmtpClient(smtpServer);
  131. mymail.Send(mailmessage);
  132.  
  133. //Disopse COM objects
  134. attachment.Dispose();
  135.  
  136. attachementCollection.Dispose();
  137. mailMessage.Dispose();
  138.  
  139. //Delete the temp file
  140. winApi::deleteFile(fileNameforEmail);
  141. CodeAccessPermission::revertAssert();
  142. //end
  143. }

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. KVO监听数组的变化

    #import "ViewController.h" @interface ViewController () @property(nonatomic,strong)NSMutab ...

  2. 2dx解析cocosbuilder中使用layer时的缺陷

    2dx解析cocosbuilder中使用layer时的缺陷 cocos2d-x 3.7 cocosbuilder中的layer通常会用到触摸属性: 但是在2dx解析布局文件的时候,却很多属性都没解析: ...

  3. hadoop2.6.0+eclipse配置

    [0]安装前的声明 0.1) 所用节点2个 master : 192.168.119.105 hadoop5 slave : 192.168.119.101 hadoop1 (先用一个slave,跑成 ...

  4. Providers、Controller 、Service、DirectiveFactory

    Providers 是唯一一种你可以传进 .config() 函数的 service.当你想要在 service 对象启用之前,先进行模块范围的配置,那就应该用 provider Controller ...

  5. android目录

    2013-09-121.activity生命周期 activity生命周期2 widget http://blog.csdn.net/xiang_j2ee/article/details/727564 ...

  6. freeCodeCamp:Where art thou

    写一个 function,它遍历一个对象数组(第一个参数)并返回一个包含相匹配的属性-值对(第二个参数)的所有对象的数组.如果返回的数组中包含 source 对象的属性-值对,那么此对象的每一个属性- ...

  7. 兼容性调试-- 在谷歌浏览器中,td 设置colspan的失效的问题

    通过设置table width="100%"table-layout="fixed" 解决

  8. 关于GrideView Item点击后出现错乱重叠的情况

    我在一个搜索页做了一个筛选信息的功能 大概思路如下:在根布局中用Include 引入一个筛选框(如图), 然后把边距设置为 android:layout_marginBottom="-250 ...

  9. Windows Kernel Way 1:Windows内核调试技术

    掌握Windows内核调试技术是学习与研究Windows内核的基础,调试Windows内核的方式大致分为两种: (1)通过Windbg工具在Windows系统运行之初连接到Windows内核,连接成功 ...

  10. 读书笔记-UIView与控件

    1.UIView 在Objective-C中,NSObject是所有类的“根”类.同样,在UIKit框架中,也存在一个如此神奇的类UIView.从继承关系上看,UIView是所有视图的根. 1.1.U ...