在项目过程中,遇到需要操作outlook信息的相关技术,遍寻,找到一些有用的。
C#操作outlook需要用到Microsoft.Office.Interop.Outlook.dll,这个文件可在微软官网寻找office PIA安装获得。
通过Alias获取用户名:
private string GetUserName(string alias)
{
Application outLookApp = new Application();
Recipient rcp = outLookApp.Session.CreateRecipient(alias);
rcp.Resolve();
return rcp.Name;
}
通过用户名获取相关信息:
Application outLookApp = new Application();
NameSpace ns = outLookApp.GetNamespace("MAPI");
AddressLists aLs = ns.AddressLists;
AddressList aL = ns.GetGlobalAddressList();
AddressEntries aEs = aL.AddressEntries;
for (int i = 1; i < aEs.Count; i++)
{
AddressEntry aE = aEs[i]; //可直接通过:aEs["UserName"]获取用户信息,但此信息不全,可用下面exchangeuser获取详细信息。
if (aE != null)
{
。。。
}
}
//获取当前用户信息
AddressEntry currentUser = aEs.Session.CurrentUser.AddressEntry;
if (currentUser.Type == "EX")
{
ExchangeUser exchUser = currentUser.GetExchangeUser();
if (exchUser != null)
{
AddressEntries addrEntries = exchUser.GetMemberOfList();//获取用户群组
if (addrEntries != null)
{
foreach (AddressEntry addrEntry in addrEntries)
{
Console.WriteLine(addrEntry.Name);
}
}
Console.WriteLine(exchUser.Alias);//获取用户alias,相关详细信息均可通过exchUser获得
}
}
更多详细信息可参考:
http://msdn.microsoft.com/en-us/library/cc513843.aspx
使用AC#工具在
Outlook
的运行实例中搜索关键字Search
Outlook
使用AC#工具在
Outlook
的运行实例中搜索关键字只需使用命令“ Search
Outlook
[搜索词]”运行该工具,它将搜索每个电子邮件帐户及其在运行中的
Outlook
实例中的子文件夹中,并将包含您搜索的关键字的所有电子邮件打印到屏幕上。
与各种C2框架(例如Cobalt Strike)的执行组装效果很好。
在编译之前,通过“项目”->“添加引用”->“ COM”->“ Micr”添加Microsoft
Office
15.0对象库
/邮件附件 filepath附件路径 ((Microsoft.
Office
.Interop.
Outlook
._MailItem)mailItem).Send();
直接cmd -->找到安装路径–>thunderbird -compose “to=zhangpeng@foxwelltech.com,subject=you email here,body=this is test,attachment=D:\1.jpeg”我的电脑VS2019添加引用也没有[Microsoft
Office
15.0 Object Library],最后我在NuGet中搜索一个添加的。就可以发送邮件了,注意:必须逗号,必须等号,必须引号,不能有空格(不包括内容)
如果你想以编程方式使用
Outlook
.com或Gmail帐户作为 SMTP主机 发送电子邮件,也有为了得到这一切工作的几件事情要注意。
使用基本的System.Net.Mail库,发送电子邮件一般是相当简单的。不过,如果你想用你的
Outlook
.Com或 Gmail帐户 作为SMTP主机发送,您将最有可能需要采取一些额外的步骤,如果你有两个阶段...
const
string
PROPERTY_NAME_EMAILL = "oldMail";//标记邮件是否读取
private static void ReadEmail()
Outlook
.
Application
app = new
Outlook
.
Application
();
Outlook
.NameSpace ns = app.GetNamespace("MAPI");
《1》右击工程文件的Reference,选择Add Reference。
《2》点击.net tab, 选择Microsoft.
Office
.Interop.
Outlook
.dll,点击 OK。
2. 添加引用:
using
Outlook
= Microsoft.
Office
.Interop.
Outlook
;
3. 代码如
写了一个简单的Windows Form程序,实现利用
Outlook
来发送电子邮件的功能。下面逐步讲解如何实现,再加上具体的代码。
打开VS2010, 新建一个Windows Form程序。
右击工程文件的Reference,选择Add Reference。
点击Com tab, 选择Microsoft.
Office
.Interop.
Outlook
.dll,点击 OK。
添加引...