Advertisement
ramkesheoran

SMTP Mail through Batch

Dec 14th, 2011
3,378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XPP 2.74 KB | None | 0 0
  1. void SMTPMail()
  2. {
  3.     str _subject;
  4.     str _bodyText;
  5.     SysEmailParameters parameters = SysEmailParameters::find();
  6.     str _emailTo = "example@domain.com";
  7.     str emailFrom = "example@domain.com";
  8.     SysMailer   mailer;
  9.     InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
  10.     ;
  11.     _subject ="Find Attachment";
  12.     _bodyText = "Dear Sir, \n Find the attachment of text file. \n\n With Regards, \n "+curuserid();
  13.     permission.assert();
  14.     permission.objectOnServer();
  15.     mailer = new SysMailer();
  16.     if (_emailTo != "")
  17.         {
  18.         if (parameters.SMTPRelayServerName)
  19.         {
  20.             mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
  21.                                parameters.SMTPPortNumber,
  22.                                parameters.SMTPUserName,
  23.                                SysEmailParameters::password(),
  24.                                parameters.NTLM);
  25.         }
  26.         else
  27.         {
  28.             mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
  29.                                parameters.SMTPPortNumber,
  30.                                parameters.SMTPUserName,
  31.                                SysEmailParameters::password(),
  32.                                parameters.NTLM);
  33.         }
  34.         mailer.fromAddress(emailFrom);
  35.         mailer.tos().appendAddress(_emailTo);
  36.  
  37.         mailer.subject(_subject);
  38.         mailer.htmlBody(_bodyText);
  39.         mailer.attachments().add("\\\\192.168.156.36\\temp\\temp.txt");
  40.         mailer.sendMail();
  41.         info("Mail Has been sent");
  42.     }
  43. }
  44. class ITL_Batch_SMTPEmail extends RunBaseBatch
  45. {
  46.     TransDate            fromdate,todate;
  47.  
  48.     #define.CurrentVersion(1)
  49.     #define.Version1(1)
  50.     #localmacro.CurrentList
  51.          fromdate,
  52.          todate
  53.     #endmacro
  54. }
  55. public void run()
  56. {
  57.     super();
  58.     this.SMTPMail();
  59. }
  60. public boolean canGoBatch()
  61. {
  62.     return true;
  63. }
  64.  
  65.  
  66.  
  67.  
  68. protected boolean canGoBatchJournal()
  69. {
  70.     return true;
  71. }
  72. Object dialog()
  73. {
  74.     DialogRunbase  dialog  = super();
  75.     ;
  76.     return dialog;
  77. }
  78. public boolean  getFromDialog()
  79. {
  80.     ;
  81.      return true;
  82. }
  83. public container pack()
  84. {
  85.     return [#CurrentVersion,#CurrentList];
  86. }
  87.  
  88.  
  89.  
  90.  
  91. public boolean unpack(container packedClass)
  92. {
  93.     Version version = RunBase::getVersion(packedClass);
  94.     ;
  95.     switch (version)
  96.     {
  97.         case #CurrentVersion:
  98.             [version,#CurrentList] = packedClass;
  99.             break;
  100.         default:
  101.             return false;
  102.     }
  103.     return true;
  104. }
  105. static void main(Args args)
  106. {
  107.     ITL_Batch_SMTPEmail  ITL_Batch_SMTPEmail;
  108.     ;
  109.     ITL_Batch_SMTPEmail = new ITL_Batch_SMTPEmail();
  110.     if(ITL_Batch_SMTPEmail.prompt())
  111.     {
  112.          ITL_Batch_SMTPEmail.run();
  113.     }
  114. }
  115.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement