MailAttachment 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化 MailAttachment 類別的新執行個體。 建議的替代做法: System.Net.Mail。
多載
MailAttachment(String) |
使用附件的指定檔案名稱,初始化 MailAttachment 類別的新執行個體。 依預設會將 Encoding 屬性設定為 UUEncode。 建議的替代做法: System.Net.Mail。 |
MailAttachment(String, MailEncoding) |
使用指定檔案名稱和附件的編碼型別,初始化 MailAttachment 類別的新執行個體。 建議的替代做法: System.Net.Mail。 |
MailAttachment(String)
使用附件的指定檔案名稱,初始化 MailAttachment 類別的新執行個體。 依預設會將 Encoding 屬性設定為 UUEncode。 建議的替代做法: System.Net.Mail。
public:
MailAttachment(System::String ^ filename);
public MailAttachment (string filename);
new System.Web.Mail.MailAttachment : string -> System.Web.Mail.MailAttachment
Public Sub New (filename As String)
參數
- filename
- String
附件檔案的名稱。
範例
//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[] {','};
foreach (string sSubstr in sAttach.Split(delim))
{
MailAttachment myAttachment = new MailAttachment(sSubstr);
myMail.Attachments.Add(myAttachment);
}
'This example shows how to programmatically add attachments
'to a mail lessage.
Dim MyMail As MailMessage = New MailMessage()
Dim iLoop1 As integer
' Concatenate a list of attachment files in a string.
Dim sAttach As String = "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.
Dim delim As Char = ","
Dim sSubstr As String
For Each sSubstr in sAttach.Split(delim)
Dim myAttachment As MailAttachment = New MailAttachment(sSubstr)
myMail.Attachments.Add(myAttachment)
Next
備註
郵件附件檔案在傳送郵件時已鎖定。
適用於
MailAttachment(String, MailEncoding)
使用指定檔案名稱和附件的編碼型別,初始化 MailAttachment 類別的新執行個體。 建議的替代做法: System.Net.Mail。
public:
MailAttachment(System::String ^ filename, System::Web::Mail::MailEncoding encoding);
public MailAttachment (string filename, System.Web.Mail.MailEncoding encoding);
new System.Web.Mail.MailAttachment : string * System.Web.Mail.MailEncoding -> System.Web.Mail.MailAttachment
Public Sub New (filename As String, encoding As MailEncoding)
參數
- filename
- String
附件檔案的名稱。
- encoding
- MailEncoding
附件的 MailEncoding 型別。