MailAttachment.MailAttachment(String) Constructor
.NET Framework 2.0
Initializes a new instance of the MailAttachment class with the specified file name for the attachment. Sets the Encoding property to UUEncode by default. Recommended alternative: System.Net.Mail.
Namespace: System.Web.Mail
Assembly: System.Web (in system.web.dll)
Assembly: System.Web (in system.web.dll)
//This example shows how to programmatically add attached files
//to a mail lessage.
MailMessage myMail = new MailMessage();
// Concatenate a list of attachment files in a string.
String sAttach = "C:\\images\\image1.jpg,C:\\images\\image2.jpg,"
+ "C:\\images\\image3.jpg";
// Build an IList of mail attachments using the files named
// in the string.
char delim[] = new char[] { ',' };
for (int iCtr = 0; iCtr < sAttach.Split(delim).get_Length(); iCtr++) {
String sSubstr = sAttach.Split(delim)[iCtr];
MailAttachment myAttachment = new MailAttachment(sSubstr);
myMail.get_Attachments().Add(myAttachment);
}
Community Additions
ADD
Show: