Outlook.MailItem 实例如何知道目标 Exchanger 服务器是什么?
我尝试从 C# 应用程序发送电子邮件,我可以通过以下几行轻松完成这项工作(我使用的是 Outlook 2003,并且有我的 Outlook 帐户):
Outlook.ApplicationClass oapp = new Outlook.ApplicationClass();
omessage = oapp.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
omessage.To = "[email protected]";
omessage.Subject = "Send From WinForm";
omessage.Body = "Hi, This message is send from a winform project.";
omessage.Send();
根据上面的代码,电子邮件可以成功发送(尽管发送电子邮件之前会显示一个警告框)。
我的问题是:当我从未在此应用程序中配置我的 Exchange 服务器时,此 omessage
项目如何知道我的 Exchange 服务器在哪里?
是否有任何方法可以从代码端获取 Exchange 服务器名称?因为我确实需要这个服务器地址。
谢谢!
I try to send an email from a C# app, and I can easily finish this job through the following lines (I am using Outlook 2003, and have my outlook account):
Outlook.ApplicationClass oapp = new Outlook.ApplicationClass();
omessage = oapp.CreateItem(Outlook.OlItemType.olMailItem) as Outlook.MailItem;
omessage.To = "[email protected]";
omessage.Subject = "Send From WinForm";
omessage.Body = "Hi, This message is send from a winform project.";
omessage.Send();
Based on the above code, the email can be sent successfully (although there a warning box will be shown before sending the email).
My question is: how does this omessage
item knows where my Exchange server is, while I never configured my Exchange Server in this app?
Does there exist any way to get the Exchange Server Name from the code side? Because I really need this server address.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用 C# Outlook dll\add-in,您的应用程序使用 Outlook 发送此邮件项目。所有属性(包括 Exchange 服务器地址)均在 Outlook 中配置。以下是在代码中公开交换服务器地址的方法:
请注意,您必须定义 Outlook.namespace 属性才能通过 MAPI 获取地址
Your using a C# outlook dll\add-in, your application uses outlook to send this mailitem. All properties including the exchange server address, are configured in outlook. Here's a method which exposes the exchange server address in code:
Note that you must define a Outlook.namespace property in order to get the address via MAPI