开发者

save .msg format file with exchange web services managed API

I'm trying to use Exchange Web Services Managed API 1.1 to connect to Exchange and then find out if an email has been sent or received and save a cop开发者_StackOverflowy of the .msg file to a folder on the disk.

So far, I have the following code

Dim service As New Microsoft.Exchange.WebServices.Data.ExchangeService(ExchangeVersion.Exchange2007_SP1)

service.AutodiscoverUrl("name@example.com")
service.UseDefaultCredentials = True
Dim ver = service.RequestedServerVersion

Dim inbox As Folder = Folder.Bind(service, WellKnownFolderName.Inbox)
Console.Out.WriteLine(inbox.UnreadCount.ToString())

Dim sentItems As Folder = Folder.Bind(service, WellKnownFolderName.SentItems)
Console.Out.WriteLine(sentItems.TotalCount.ToString())

What I want is to fire an event which saves the email (in .msg format) to the file system. But I can't seem to find any way to do this with the EWS Managed API, I would settle for a function to call to see if new messages exist since last call or similar without preforming searches all the time. I would rather not implement this as an outlook plugin because we need it to work seamlessly with the web version as well as the full client.


I couldn't find any direct way to do with within the framework so I used Redemption and the following code to resolve it:

Dim redSess As Redemption.RDOSession = CreateObject("Redemption.RDOSession")
Dim savedMsg = redSess.GetMessageFromMsgFile("c:\test_ews_m_API2.msg", True)
savedMsg.Import("c:\test_ews_m_API.eml", 1024)
savedMsg.Save()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜