adding Outlook Attachments generates exception

  • Thread starter Thread starter Peter Wullems
  • Start date Start date
P

Peter Wullems

I use C# to parse incoming emails for a predefined type and structure of
message content and construct replies automatically, attach a file and place
the generated emails in the drafts folder. There I can review and decide
which ones to send.

The program was working fine the other day and then decided to stop with the
following message:
Can't create file: filename.doc. Right-click the folder you want to create
the file in, and then click Properties on the shortcut menu to check your
permissions for the folder.

The exception is raised on calling MailItem.Attachments.Add().

I do not understand why it whould work about 50 times and then for exactly
the same files, raise an exception. The change happened during a program
run.

If I comment out the call to Attachments.Add() everything works again. As I
understand it, attaching a file should not be creating a file or am I wrong
in this. If it were creating a file, permissions should exist for the
directory where Outlook resides. I do not have this in my profile (the
default), but in a directory in a drive dedicated to data that is accessible
by all profiles. I do not use the shared documents folder for this.

Everything tends to point in the direction of this being a security issue.
Why should this be different than before and what would trigger the changed
perception.

I recently installed XP service pack 2 for XP Pro and changed my firewall to
use the one in Windows but it worked for about 50 emails using the inbuilt
firewall and then stopped. I wonder if Outlook or the firewall detects
heavy or unusual activity. My program (console applic) can create something
like 200 emails in a single run with duration of maybe a minute.

any help would be apppreciated.

cheers

peter
 
A few more comments.

If I attempt to attach the file manually I get the same problems.

If I cut and paste the contents of the file to be attached to a new file, I
can attach that new file. This applies to both manual and programatic
attachments. To my mind this confirms that this is a permissions thing, but
where and how? The permissions for the original file was still set to
unrestricted so it would appear to be something that Outlook does in an
attempt to protect itself perhaps.

cheers

Peter
 
Back
Top