Reputation: 1039
I am trying to attach some pdf document when sending email but I get above error when I try to attach.
code I am using is:
Attachment a = new Attachment("External_path", MediaTypeNames.Application.Octet);
External_Path points to pdf on external website and can confirm it exists. I have also tried chaing MediaTypeNames to 'MediaTypeNames.Application.Pdf'
but that didn't work either.
Has someone experienced same problem while attaching attachments to an email?
Upvotes: 0
Views: 891
Reputation: 9772
The documentation of Attachment
says, the constructor must be called with a file path. What you use is an URL.
You must download the document to a local (temporary) file and read it from there.
Upvotes: 1