+1 vote

I am testing Mail.net for use in our office to download email attachments. Everything works, except I receive "Access to the path 'C:\temp' is denied." error every time I test it.

I tried different locations local and network and all are denied.

Would you please tell if this can be fixed in the code or it is because I use free download? We plan to purchase it after confirmed it works for what we need to do.

Thank you for your help.

by

1 Answer

0 votes
 
Best answer

This error has nothing to do with Mail.dll.

Your application must have enough permissions to create a file in the
specified location.

Make sure that you are escaping path separator ('\') correctly (for example by using using '@' character at the string beginning):

attachment.Save(@"c:\path\file.dat");

Make also sure that you are specification attachment's file name in the path. You can use MimeData.SafeFileName for that:

attachment.Save(Path.Combine(@"c:\path\", attachment.SafeFileName));
by (301k points)
...