MailMessage.Attachments 属性

定义

指定随电子邮件一起传送的附件集合。 建议使用的替代项:System.Net.Mail

public:
 property System::Collections::IList ^ Attachments { System::Collections::IList ^ get(); };
public System.Collections.IList Attachments { get; }
member this.Attachments : System.Collections.IList
Public ReadOnly Property Attachments As IList

属性值

IList

IList 对象的 MailAttachment 集合。

示例

MailMessage MyMessage = new MailMessage();
MyMessage.Attachments.Add(new MailAttachment(fileName1));
MyMessage.Attachments.Add(new MailAttachment(fileName2, MailEncoding.UUEncode));
Dim MyMessage As MailMessage = new MailMessage()
MyMessage.Attachments.Add(New MailAttachment(fileName1))
MyMessage.Attachments.Add(New MailAttachment(fileName2, MailEncoding.UUEncode))

注解

可以通过调用 Message.Attachments.Add(MyMailMessage)将新附件添加到邮件中。 请参阅 Send 有关用法的示例 SmtpMail

适用于