I plan on creating a windows service that will monitor an exchange mailbox for mails with particular subject. The attachments from such emails need to be stored in a specific folder on the network share. I believe I can achieve this using Exchange Web Services Managed API (us开发者_开发知识库ing Exchange 2007 SP1).
If you have experience with this, please share some samples or links other than the MSDN link below that can give me a jump start.
http://msdn.microsoft.com/en-us/library/dd633696%28v=EXCHG.80%29.aspx
Lets say these mails are coming into your Inbox on X mailbox. You create a subscription to that folder like so
PullSubscription subscription =
SomeExchangeService.SubscribeToPullNotifications(
new FolderId[]{ WellKnownFolderName.Inbox },1440,"",EventType.Created);
Subscriptions.Add(subscription);
Now you have to set a timer and check the pull notifs
static void Exchanger_Elapsed(object sender, ElapsedEventArgs e)
{
foreach (var pullSubscription in Subscriptions)
{
foreach (var itemEvent in pullSubscription.GetEvents().ItemEvents)
{
Item item = Item.Bind(SomeExchangeService, itemEvent.ItemId);
if (item.Subject == someString)
{
// item.Attachments do something
// As in read it as a stream and write it
// to a file according to mime type and file extension
}
}
}
}
I hope this helps...
UPDATE Due to email request
public static List<PullSubscriptionpublic static List<PullSubscription> Subscriptions = new List<PullSubscription>();> Subscriptions = new List<PullSubscription>();
Consider creating a search folder to screen the messages. You will only need to look for, and process, messages in the search folder.
精彩评论