Am trying to add an attachment to mail in asp.net VB.
I could send mail fine until I added the attachment code,
Dim attch As Attachment = New Attachment("http://sitehere.com/Documents/file.jpg")
mail.Attachments.Add(attch)
I am getting the error URI formats are not supported.
Any ideas why that is and what I can do about it?
The
Attachmentclass expects either a path to a file on the file system, or aStream.Try:
That’s me doing my best to translate from C# to VB.NET so the syntax might not be 100% correct, but that’s the general idea. That will download the data into a byte array, then create a memory stream from those bytes and pass that to the Attachment constructor.