本文整理汇总了C#中OpenPop.Mime.Message.FindAllAttachments方法的典型用法代码示例。如果您正苦于以下问题:C# Message.FindAllAttachments方法的具体用法?C# Message.FindAllAttachments怎么用?C# Message.FindAllAttachments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenPop.Mime.Message
的用法示例。
在下文中一共展示了Message.FindAllAttachments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: add_attachments
///////////////////////////////////////////////////////////////////////
public static void add_attachments(Message message, int bugid, int parent_postid, IIdentity identity)
{
foreach (MessagePart attachment in message.FindAllAttachments())
{
add_attachment(attachment.FileName, attachment, bugid, parent_postid, identity);
}
}
示例2: GetMailMessageFromMessage
private MailMessage GetMailMessageFromMessage(Message msg)
{
var mailMessage = msg.ToMailMessage();
mailMessage.Attachments.Clear();
var attachParts = msg.FindAllAttachments();
foreach (var part in attachParts)
{
var attachment = new System.Net.Mail.Attachment(new MemoryStream(part.Body), part.FileName, part.ContentType.MediaType);
mailMessage.Attachments.Add(attachment);
}
return mailMessage;
}
示例3: TestComplexMultiPartMessage
public void TestComplexMultiPartMessage()
{
const string multiPartMessage =
"MIME-Version: 1.0\r\n" +
"From: Nathaniel Borenstein <[email protected]>\r\n" +
"To: Ned Freed <[email protected]>\r\n" +
"Date: Fri, 07 Oct 1994 16:15:05 -0700 (PDT)\r\n" +
"Subject: A multipart example\r\n" +
"Content-Type: multipart/mixed;\r\n" +
"\t\t\t\t\t\t boundary=unique-boundary-1\r\n" +
"\r\n" +
"This is the preamble area of a multipart message.\r\n" +
"Mail readers that understand multipart format\r\n" +
"should ignore this preamble.\r\n" +
"\r\n" +
"If you are reading this text, you might want to\r\n" +
"consider changing to a mail reader that understands\r\n" +
"how to properly display multipart messages.\r\n" +
"\r\n" +
"--unique-boundary-1\r\n" +
"\r\n" +
" ... Some text appears here ...\r\n" +
"--unique-boundary-1\r\n" +
"Content-type: text/plain; charset=US-ASCII\r\n" +
"\r\n" +
"This could have been part of the previous part, but\r\n" +
"illustrates explicit versus implicit typing of body\r\n" +
"parts.\r\n" +
"--unique-boundary-1\r\n" +
"Content-Type: multipart/parallel; boundary=unique-boundary-2\r\n" +
"\r\n" +
"--unique-boundary-2\r\n" +
"Content-Type: audio/basic\r\n" +
"Content-Transfer-Encoding: base64\r\n" +
"\r\n" +
"dGVzdCBhdWRpbw==\r\n" + // "test audio" in base64
"--unique-boundary-2\r\n" +
"Content-Type: image/jpeg\r\n" +
"Content-Transfer-Encoding: base64\r\n" +
"\r\n" +
"dGVzdCBpbWFnZQ==\r\n" + // "test image" in base64
"--unique-boundary-2--\r\n" +
"\r\n" +
"--unique-boundary-1\r\n" +
"Content-type: text/enriched\r\n" +
"\r\n" +
"This is <bold><italic>enriched.</italic></bold>\r\n" +
"<smaller>as defined in RFC 1896</smaller>\r\n" +
"\r\n" +
"Isn\'t it\r\n" +
"<bigger><bigger>cool?</bigger></bigger>\r\n" +
"--unique-boundary-1\r\n" +
"Content-Type: message/rfc822\r\n" +
"\r\n" +
"From: Test <[email protected]>\r\n" +
"To: Test <[email protected]>\r\n" +
"Subject: Test subject\r\n" +
"Content-Type: Text/plain; charset=ISO-8859-1\r\n" +
"Content-Transfer-Encoding: Quoted-printable\r\n" +
"\r\n" +
"... Additional text in ISO-8859-1 goes here ... 3 + 5 =3D 8\r\n" +
"--unique-boundary-1--";
// No special characters used - we can use ASCII to get the bytes
Message message = new Message(Encoding.ASCII.GetBytes(multiPartMessage));
Assert.AreEqual("1.0", message.Headers.MimeVersion);
// From
Assert.AreEqual("Nathaniel Borenstein", message.Headers.From.DisplayName);
Assert.AreEqual("[email protected]", message.Headers.From.Address);
// To
Assert.NotNull(message.Headers.To);
Assert.AreEqual(1, message.Headers.To.Count);
Assert.AreEqual("Ned Freed", message.Headers.To[0].DisplayName);
Assert.AreEqual("[email protected]", message.Headers.To[0].Address);
// Date
Assert.AreEqual("Fri, 07 Oct 1994 16:15:05 -0700 (PDT)", message.Headers.Date);
// -0700 is the same as adding 7 hours in the UTC DateTime
Assert.AreEqual(new DateTime(1994, 10, 7, 23, 15, 05, DateTimeKind.Utc), message.Headers.DateSent);
// Subject
Assert.AreEqual("A multipart example", message.Headers.Subject);
MessagePart part1 = message.MessagePart;
Assert.AreEqual("multipart/mixed", part1.ContentType.MediaType);
Assert.IsTrue(part1.IsMultiPart);
Assert.NotNull(part1.MessageParts);
Assert.IsNull(part1.Body);
// There is a total of 5 multiparts in the first message (unique-boundary-1)
Assert.AreEqual(5, part1.MessageParts.Count);
// Fetch out the parts, which are checked against later
System.Collections.Generic.List<MessagePart> attachments = message.FindAllAttachments();
System.Collections.Generic.List<MessagePart> textVersions = message.FindAllTextVersions();
// We are now going one level deeper into the message tree
//.........这里部分代码省略.........
示例4: treeViewEmails_AfterSelect
private void treeViewEmails_AfterSelect(object sender, TreeViewEventArgs e)
{
// Console.WriteLine(e.Node.Index);
//init email viewer
string strEmail = treeViewAccounts.SelectedNode.Text;
string dirPath =AppDomain.CurrentDomain.BaseDirectory + @"data\inbox\" + strEmail;
string shortFile = m_dicEmails[strEmail][e.Node.Index].file;
string strUrl = "file://" + dirPath + "\\" + shortFile + ".htm";
Console.WriteLine(strUrl);
Uri uri = new Uri(strUrl);
webBrowserMailContent.Url = uri;
//init attachment
Message message = new Message(File.ReadAllBytes(dirPath + "\\" + shortFile + ".eml"));
// Build up the attachment list
List < MessagePart > attachments = message.FindAllAttachments();
treeViewAttach.Nodes.Clear();
foreach (MessagePart attachment in attachments)
{
// Add the attachment to the list of attachments
TreeNode addedNode = treeViewAttach.Nodes.Add((attachment.FileName));
// Keep a reference to the attachment in the Tag property
addedNode.Tag = attachment;
}
}