我得到错误“mailformat在当前上下文中不存在”。 [英] Im getting the error "mailformat doesn't exist in current context".

查看:66
本文介绍了我得到错误“mailformat在当前上下文中不存在”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我尝试发送邮件时出现以下错误。

mailformat在当前上下文中不存在



private void button2_Click(object sender,EventArgs e)

{



Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();

Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft。 Office.Interop.Outlook.OlItemType.olMailItem);



尝试

{

mailItem.Subject =这是主题;

mailItem.To =someexample @;

mailItem.CC =someexample @; some @;

mailItem.Body =这是消息。;

mailItem.BodyFormat = MailFormat.Html;









mailItem.Display(false);



}

catch(例外情况ex)

{

MessageBox.Show(错误! + ex.Message);

}

}

Hi,

I have the following error when I tried to send the mail.
mailformat doesn't exist in current context

private void button2_Click(object sender, EventArgs e)
{

Microsoft.Office.Interop.Outlook.Application app = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.MailItem mailItem = app.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

try
{
mailItem.Subject = "This is the subject";
mailItem.To = "someexample@";
mailItem.CC = "someexample@;some@";
mailItem.Body = "This is the message.";
mailItem.BodyFormat = MailFormat.Html;




mailItem.Display(false);

}
catch (Exception ex)
{
MessageBox.Show("Error! " + ex.Message);
}
}

推荐答案

尝试
OlBodyFormat.olFormatHTML





参考 - OlBodyFormat枚举 [ ^ ]


这篇关于我得到错误“mailformat在当前上下文中不存在”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆