请教MAPI发送邮件问题

hanqing_liu 2018-03-05 02:44:05
因为要实现outlook和Foxmail 两种客户端的发送邮件功能,所以采用调MAPI
现MAPI发送文本信息已经可以了,但是不知道发送HTML内容需要怎么处理,请教大神。

直接传HTML的话会当文本处理


[DllImport("MAPI32.DLL")]
static extern int MAPISendMail(IntPtr sess, IntPtr hwnd, MapiMessage message, int flg, int rsv);

int SendMail(string strSubject, string strBody, int how)
{
MapiMessage msg = new MapiMessage();
msg.subject = strSubject;
msg.noteText = strBody;

msg.recips = GetRecipients(out msg.recipCount);
msg.files = GetAttachments(out msg.fileCount);

m_lastError = MAPISendMail(new IntPtr(0), new IntPtr(0), msg, how, 0);
if (m_lastError > 1)
MessageBox.Show("MAPISendMail failed! " + GetLastError(), "MAPISendMail");

Cleanup(ref msg);
return m_lastError;
}
...全文
298 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
SoulRed 2018-03-06
  • 打赏
  • 举报
回复
richtext不是传输的问题。是解码的问题。你的控件(textbox)应该改为richTextBox一类的控件, 你可以搜一下能符合你要的富文本编辑器来满足你的需求
hanqing_liu 2018-03-06
  • 打赏
  • 举报
回复
这个看过了,还是没用,求指导
  • 打赏
  • 举报
回复
只能指路了,官方文档: https://msdn.microsoft.com/en-us/library/windows/desktop/dd296720(v=vs.85).aspx 骨头就不帮你啃了,办公室没google

110,533

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧