Limeoats
Limeoats

Reputation: 426

MailMessage Attachment on IIS Server

I am currently having an issue where I am creating a MailMessage with attachments. This works perfectly well on a local server, however once it is moved to a remote server, the application is unable to find the files that were attached. The code I am using is:

foreach (string s in e.attachments)
{
    mail.Attachments.Add(new Attachment(s));
}

Where e.attachments is simply a List<string> of paths to files on the client's computer.

The error message I am receiving is:

Error message

I'm assuming this is happening because the application is looking at the C: drive of the server it is running on. How would I go about solving this issue?

Upvotes: 0

Views: 158

Answers (1)

Martin E
Martin E

Reputation: 319

You first have to upload the attachment to the server. As you say, the file you are trying to attach is on your local storage and not on your webserver.

This post should help you uploading your attachments:

Cheers, Martin

Upvotes: 1

Related Questions