To send mail you can try code in following way in job . You can then set this code in your way in form or dialog .
str sendereml = 'sendereml@domainname.com';
str recipienteml= 'recipient@domainname.com';
str cc1 = 'cc@domainname.com';
str subject = 'Testing';
str MailBody = 'Testing mail txt -hello how r u';
str fileName1 = @'C:\Testing1.txt';
Set permissionSet;
System.Exception e;
str mailServer;
System.Net.Mail.SmtpClient mailClient;
System.Net.Mail.MailMessage mailMessage;
System.Net.Mail.MailAddress mailFrom;
System.Net.Mail.MailAddress mailTo;
System.Net.Mail.MailAddressCollection mailCCCollection;
System.Net.Mail.AttachmentCollection mailAttachementCollection;
System.Net.Mail.Attachment mailAttachment;
;
try
{
permissionSet = new Set(Types::Class);
permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
permissionSet.add(new FileIOPermission(filename1, 'rw'));
CodeAccessPermission::assertMultiple(permissionSet);
mailServer = SysEmaiLParameters::find(false).SMTPRelayServerName;
mailClient = new System.Net.Mail.SmtpClient(mailServer);
mailFrom = new System.Net.Mail.MailAddress(sendereml);
mailTo = new System.Net.Mail.MailAddress(recipient);
mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);
mailCCCollection = mailMessage.get_CC();
mailCCCollection.Add(cc1);
mailMessage.set_Priority(System.Net.Mail.MailPriority::High);
mailMessage.set_Subject(subject);
mailMessage.set_MailBody(MailBody);
mailAttachementCollection = mailMessage.get_Attachments();
mailAttachment = new System.Net.Mail.Attachment(fileName1);
mailAttachementCollection.Add(mailAttachment);
mailClient.Send(mailMessage);
mailMessage.Dispose();
CodeAccessPermission::revertAssert();
info("Email has been sent.");
}
catch (Exception::CLRError)
{
e = ClrInterop::getLastException();
while (e)
{
info(e.get_Message());
e = e.get_InnerException();
}
CodeAccessPermission::revertAssert();
}
}