In the Visual C# MailMessage class, how do you remove an attachment?
We have modified the code on a project I am working on. Part of the modifications seem to impact code that has not changed at all.
It would appear that now a part of the code that added attachments to email (using the "MailMessage" class) is failing because those email attachments are located on a secure server.
And so, as a test, it would be interesting to implement a piece of code that would remove the attachment upon a failure of the SmtpClient Send (which passes a MailMessage class as a parameter). If I am using .Attachments.Remove, it asks for an Attachment class. Where and how do I assign this?
Here is the error that I get which describes the proper use of the Remove method, when I type "Mail.Attachments.Remove()" with "Mail" being a MailMessage class:
bool Collection<Attachment>.Remove(Attachment item) Removes the first occurance of a specific object from the System.Collections.ObjectMode.Collection<T>, C#: Unknown method 'Remove()' of 'system.Net.Mail.AttachmentCollection'