Outlook Interop: Attachments.Add throws Exception

F

Ferdinand Zaubzer

I have a Problem of creating a large number of emails with attachments.
Everything works fine, but when the 100th mail is created and the
attachment is added

mail.Attachments.Add(fileName, (int)OlAttachmentType.olByValue,
mail.Body.Length + 1, "My Attachment");

throws an Exception telling me the following: (Translated from German)
The file <filename> cannot be created. Check the permissions of the
folder where you want to create the file.

The code for creating all the mails is the following:

foreach (Recipient rec in Recipients){
_MailItem mail = outlookApp.CreateItem(OlItemType.olMailItem);

mail.To = rec.address;
mail.Body = rec.body;
mail.Subject = rec.subject;

mail.Attachments.Add(rec.pathToAttachment,
(int)OlAttachmentType.olByValue,
mail.Body.Length + 1, "My Attachment");

mail.Save();
mails.Add(mail); //save mails references in an Arraylist to be
able to send them later, after checking
mails in Draftfolder.
}

Can anyone help me with this problem
Thanks
 
S

Sue Mosher [MVP-Outlook]

See my response to your other post on this issue.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top