Sending Email Attachment through Batch


I am using Axapta 3.0 and I have been trying with no success to send an email with an attachment through batch. It fails to attach file. I am using the sysMailer class. It works fine interactive from menu. This is my code. I have also tried \server\folder\ path also with no success. I am running the batch process from my local pc. Thanks in advance for any help.

SysMailer mailer;

mailer = New SysMailer();

mailer.fromName(‘Shipping Update’);


mailer.body(“Please find attached Shipping Update” );

Hi Hudson,

I have done the same thing but still not getting the attachment mailed.I have made use of dialogue box in which system asks user to attach a file and then the file path as a string has been passed in mailer.attachments().add(“filepath”);. But system is showing the error “Error opening the file ''C:/Kanu.pdf”, The file is write-protected or in use".

Please help me if you can.

Thanks in advance.

Hi Kannu,

I have not worked with Axapta for over a year now, but from what I can remember, I was not able to get the batch job to send an attachment. I think my error was it could never find the file. At least you batch job seems to find the file. I was able to run the program and send and attachment by creating a menu option and running interactively but could never get the batch to work. Because it was a batch job…I wasnt sure if the process to attach the document occured at the server causing my error of not finding the document. This probably doesnt help you much but I wanted to let you know what I knew.

Thanks Hudson!!! :slight_smile:

I will try out something else then…