Email setup - Job

Hi,

All the mail setup i have done and one test job i wrote and i am trying to send one test mail , while running job i am getting error like & My coding is

static void Theaxapta_EmailJob(Args _args)

{

str sender = ‘palanivel.r@rasiseeds.com’;

str recipient = ‘velmbait@gmail.com’;

str cc1 = ‘cc@somedomain.com’;

str subject = ‘Test’;

str body = ‘Test’;

str fileName1 = @‘C:\test.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(sender);

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_Body(body);

mailAttachementCollection = mailMessage.get_Attachments();

mailAttachment = new System.Net.Mail.Attachment(fileName1);

mailAttachementCollection.Add(mailAttachment);

mailClient.Send(mailMessage);

mailMessage.Dispose();

CodeAccessPermission::revertAssert();

info(“Email sent.”);

}

catch (Exception::CLRError)

{

e = ClrInterop::getLastException();

while (e)

{

info(e.get_Message());

e = e.get_InnerException();

}

CodeAccessPermission::revertAssert();

}

}

error :

object ‘CLRobject’ could not be created

any one help me

Thanks

palani

Was posted to “Membership Questions” forum (for question about your membership of DUG). Moved to the AX End user forum.

Which line of code is causing the error?