标签:get uid init attr getname 发件人 ini format ddr
获取outlook发件人
1.1场景
使用Outlook发送邮件时实时获取发件人
1.2代码
特性: [GuidAttribute("EDF9F510-B728-48CA-A202-A7D201933C14"), ProgId("SinitekOutlook.Connect")]
特性用于反射,给类增加字段、属性,再由反射处理。
outlook所需继承接口:
Object, IDTExtensibility2, IRibbonExtensibility, ICustomTaskPaneConsumer
MailItem mailItem = null;
mailItem = (MailItem)WriteUtil.Application.CreateItem(OlItemType.olMailItem);
mailItem.BodyFormat = OlBodyFormat.olFormatPlain;
mailItem.Display();
WriteUtil.CMailItem = mailItem;
MailItem noteItem = new MailItem ();
Account account = noteItem.SendUsingAccount;
//发件人
string curuser = "";
if (MailItem!= null)
{
MailItem noteItem = WriteUtil.CMailItem;
Account account = noteItem.SendUsingAccount;
//发件人
? string senduser = account.SmtpAddress;
if (account != null)
{
curuser = account.SmtpAddress;
}
else
{
MSOutlook.Application myOutlookApp = new MSOutlook.Application();
NameSpace myNameSpace = myOutlookApp.GetNamespace("MAPI");
MAPIFolder myFloder = myNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderContacts);//获取默认邮箱信息
Recipient myFolderInbox = myNameSpace.CurrentUser;
curuser = myFolderInbox.Address;
}
}
标签:get uid init attr getname 发件人 ini format ddr
原文地址:https://www.cnblogs.com/CoolYee/p/14658918.html