简体   繁体   English

有没有一种简单的方法可以将Microsoft.Office.Interop.Outlook.MailItem转换为System.Net.Mail.MailMessage?

[英]Is there an easy way to convert from Microsoft.Office.Interop.Outlook.MailItem to System.Net.Mail.MailMessage?

The title pretty much says it all. 标题基本概括了所有内容。 I have an Outlook interop MailItem . 我有一个Outlook互操作MailItem I'd like to create a System.Net.Mail MailMessage from the MailItem , modify a few properties (such as the sender), and then send it. 我想从MailItem创建一个System.Net.Mail MailMessage ,修改一些属性(例如发件人),然后发送它。 Is this something that must be done manually, or do either of these libraries (or a third party library) provide a simple way to achieve this? 这是必须手动完成的事情,还是这些库(或第三方库)提供了一种简单的方法来实现?

MailItem from Outlook and MailMessage from the .NET Framework are very different things. Outlook中的MailItem和.NET Framework中的MailMessage是非常不同的东西。

You need to do a lot of work manually: 您需要手动完成很多工作:

  1. Copy simple properties like subject, sender, to/cc/bcc lists. 将主题,发件人等简单属性复制到/ cc / bcc列表。
  2. Fetch all body formats and create new bodies in MailMessage . 获取所有正文格式并在MailMessage创建新的正文。
  3. Fetch and store attachments from MailItem using temporary files or memory streams. 使用临时文件或内存流从MailItem获取并存储附件。
  4. Create new attachments for MailMessage using stored data from the previous point. 使用上一点的存储数据为MailMessage创建新附件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过指定发件人地址使用Microsoft.Office.Interop.Outlook.MailItem发送邮件 - How to send a mail using Microsoft.Office.Interop.Outlook.MailItem by specifying the From Address Microsoft.Office.Interop.Outlook.MailItem不包含发件人的定义…? - Microsoft.Office.Interop.Outlook.MailItem does not contain a definition for Sender…? 访问Microsoft.Office.Interop.Outlook.MailItem的属性 - Accessing properties of Microsoft.Office.Interop.Outlook.MailItem 无法从“对象”转换为“ System.Net.Mail.MailMessage” - cannot convert from 'object' to 'System.Net.Mail.MailMessage' 为什么我无法从“ MimeKit.MimeMessage”转换为“ System.Net.Mail.MailMessage”? - Why am I getting cannot convert from 'MimeKit.MimeMessage' to 'System.Net.Mail.MailMessage'? 转换为 system.net.mail.mailMessage 错误 - converting to system.net.mail.mailMessage error 使用System.Net.Mail.MailMessage时设置“发件人”地址吗? - Set “From” address when using System.Net.Mail.MailMessage? 从字符串加载System.Net.Mail.MailMessage - System.Net.Mail.MailMessage Load from a String System.Net.Mail.Mailmessage可以继承吗? - Can System.Net.Mail.Mailmessage be inherited? 怎么把OpenPop.NET MailMessage转换成System.Net.Mail.MailMessage? - How to convert OpenPop.NET MailMessage to System.Net.Mail.MailMessage?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM