Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Attachment Sometimes Fails

Status
Not open for further replies.

PM2000

Programmer
Aug 18, 2000
42
BM
Hi,

I have an vb.net app that emails attachment(s) as designated by the user to a list of people. There can be one or many attachments as selected by the user on the form. The following code generates the email:

oMailitem = oOutlook.CreateItem(Outlook.OlItemType.olMailItem)

oMailitem.To = "someone@somewhere.com"
oMailitem.Subject = "Emailing attachments"
oMailitem.Body = "Some sort of text."

'Attach any attachments
For a = 0 To dtAttach.Rows.Count - 1
drAttach = dtAttach.Rows(a)
oMailitem.Attachments.Add(drAttach.Item(1).ToString)

Next

oMailitem.Send()

The code works fine for awhile as it loops through the list of people to send to and grabs the attachment(s), but eventually I start getting the following message:

"Can't create file: finename.doc. Right-click on the folder you want to create the file in, and then click Properties on the shortcut menu to check your permissions on the folder."

So - it seems like I have lost permission to access the folder. However, this is definately not the case.

Has anyone come accross this?

Thanks,
Peter
 
This is just a thought, having developed something similar but using MAPI controls.

When using MAPI I found, that I had to add an extra space to the body text of the mail, for each attachment that the mail contained.




Sweep
...if it works dont mess with it
 
Thanks Sweep.

I tried to add the space, but got the same error.

So, I tried something a bit different. I use filecopy to copy the attachment and give the copied file a unique name. Then I attach the copied file, send the email, and then delete the copied file. For whatever reason, this works like a charm.

If anyone wants the code, just let me know.

Peter
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top