Mail pupose

hi,

I have written the coding for report sending purpose in Axapta if am running the report i am getting the mail in outlook .But in batch process involving that report that time not working fine , in attachment command after that coming error CLR Object not initialized like error i am getting.

void SendMail(str filename)

{

//System.Net.Mail.MailMessage mailMessage;

System.Net.Mail.Attachment attachment;

System.Net.Mail.AttachmentCollection attachementCollection;

// System.Net.Mail.SmtpClient smtpClient;

System.Net.Mail.MailAddress mailAddressFrom;

System.Net.Mail.MailAddress mailAddressTo;

str strBody;

str strSMTPServer;

str strFileName;

FileIOPermission perm;

;

// preparing parameters

permissionSet = new Set(Types::Class);

permissionSet.add(new InteropPermission(InteropKind::ClrInterop));

permissionSet.add(new FileIOPermission(filename, ‘rw’));

CodeAccessPermission::assertMultiple(permissionSet);

mailFrom = new System.Net.Mail.MailAddress(‘axapta@rasiseeds.com’,“Axapta”);

mailTo = new System.Net.Mail.MailAddress(“palanivel.r@rasiseeds.com”);//baskaran.s@rasi.in;saravanan.r@rasiseeds.com’);

strBody = “There is a email body”;

strSMTPServer = “rasivqs3.mail.pairserver.com”;

// preparing mail with body, subject, from, to.

mailMessage = new System.Net.Mail.MailMessage(mailFrom, mailTo);

mailmessage.set_Subject(“There is a email subject”);

mailmessage.set_Body(strBody);

attachementCollection = mailMessage.get_Attachments();

strFileName = “C:\tmp\6.pdf”;

// assert permision

perm = new FileIOPermission(strFileName,‘w’);

perm.assert();

// attaching file to that email.

attachment = new System.Net.Mail.Attachment(strFileName);

attachementCollection.Add(attachment);

smtpClient = new System.Net.Mail.SmtpClient(strSMTPServer);

smtpClient.Send(mailmessage);

// release permision

CodeAccessPermission::revertAssert();

}

Some one plz help me

Thanks

Palani

You Should Post question in AXAPTA forum … You will get faster response…

Amol,

hi, while doing batch process in that coding report its not happening error its coming like " CLR object not created like" , In step by step i checked the debugging in attachment query only sending error message but with out batch processing its working fine.

Thanks

Palani