- Home
- 製 品
- 購 入
Order Online Ordering Info Resellers - ダウンロード
- サポート
サポート依頼(英語) ライブチャット(英語) ナレッジベース(英語) Webフォーラム(英語) オンラインドキュメント(英語) FAQ(英語) チュートリアル(英語) - サービス
インストール データ移行 インテグレーション 製品カスタマイズ カスタムソフト開発 - Community Editions
- お問い合せ
Back to Tutorials list
Back to Tutorials list
Access Message Attachments
All the message attachments are stored in MailMessage.Attachments collection. This collection also lists the embedded images and other files which are contained in the message.
Indexing of attachments in the collection is zero based. For example, the code below prints the name of the first attachment:
[C#]
Console.WriteLine("Attachment name is " + msg.Attachments[0].Name);
[VB.NET]
Console.WriteLine("Attachment name is " + msg.Attachments(0).Name)
To access attachments, you need to download the entire message from the server (not just headers).
You can check whether the message has attachments as follows:
[C#]
Pop3 pop = new Pop3();
// Download entire message
MailMessage msg = pop.DownloadEntireMessage(1);
if (msg.HasAttachments)
{
// The message has at least one attachment
}
[VB.NET]
Dim pop As New Pop3()
' Download entire message
Dim msg As MailMessage = pop.DownloadEntireMessage(1)
if (msg.HasAttachments) Then
' The message has at least one attachment
End If
In some cases, you can use MailMessage.HasAttachments property even if only message header has been downloaded. See Determine if the message has attachments without downloading the entire message for details.