Welcome to MSDN Blogs Sign in | Join | Help

Jive into Messaging world

Everyday is a Challenge, I am loving it...

News

Are you using Exchange Web Services ?

If yes then I would like to hear from you. Your experiences, challenges, things you feel are barriers and things that could make it even better. Do you need samples? What sort of operations you want to perform using Exchange Web Services?

You may ask me why I want to know all this.. well... I am developer support engineer at Microsoft. Exchange Web Services is one among the various other messaging APIs that I work upon and support. I am a big fan of Exchange Web Services and the way it has been implemented in Exchange. If I look at the future, I could see EWS being only API capable of competing and complementing MAPI.

This is NOT a official forum, but I would like to put my best efforts in helping you with all your queries related to EWS. I would take requests for HOWTO samples. If you have any questions, any doubts, migrating to Exchange 2007 and worried about your exiting applications working on WebDAV and other APIs not recommended or supported under Exchange 2007, you can ping me for help.

I would try my level best to help you.

So... start shooting.. now!

Posted: Monday, August 11, 2008 6:34 AM by Vikas Verma

Comments

Rudolf said:

Hi, I'm using webservices to programattically auto-reply on incoming emails. I find it hard to understand the way how things work. Also beacause there's a lack of examples on the net.

I'm trying to set up a little program that responds on a new mail event. It has to extract the attachment. handle the data in the attachment en reply with a new email with attachment. this application has to be up and running 'for ever'.

any suggestions?

thanx in advance

greets,

Rudolf

# September 23, 2008 5:32 AM

Vikas Verma said:

Rudolf,

You need to use Push/Pull Notifications to receive events for every new mail that you receive. Using EWS you can call GetAttachment to download the content of attachment and parse it accordingly. Once done you can call a CreateItem and send it to the users.

Read more about Notification Subsystem here

http://blogs.msdn.com/vikas/archive/2007/08/28/ews-exchange-2007-notification-subsystem.aspx

I have couple of samples for Notification that I will update on that blog post later today. Also I will add more links to the resources to the same blog.

# September 23, 2008 5:56 AM

Sholofly said:

Vikas,

I think i have a solution for my problem...(But i'm still interested in yours :) ) :

Using FindItemType with a restriction(message must be  unread) 'gives me' an ArrayOfRealItems with itemtypes. I can cast that itemtypes to messages so i can acces all info that i need :D

I was wondering: Why are there so much examples for sending mail with EWS but less examples of (auto) receiving. I was searching the net for two days, looking for information :s Besides the (minimal) information on MSDN there was only one proper place for finding someone who can Jive with me :D

Thanx!

# September 24, 2008 3:06 AM

Christian said:

Hi Vikas,

I need the push notification on a public folder.

Using the SDK (July 2007) I found the push notification sample for a account and it works.

Well, in the SDK (SP1 August 2008) I read the information, that the push notification is now available for public folders, too. I can not find any sample how to do this. Can you please help me?

Thanks

Christian

# September 30, 2008 10:05 AM

Vikas Verma said:

Christian,

Public folder support was included in SP1. You can treat the public folder in a similar manner as you would treat any other folder.

Do a FindFolder or GetFolder to get the PF's itemId and bind the Push Notification to that. Everything else will work exactly the same.

Make sure you get your proxy classes from SP1 and are passing Exchange_SP1 header in soap commands

# September 30, 2008 1:45 PM

Christian said:

Hi Vikas,

thanks for your help.

I got the ID from the public folder. With the following code I try to bind the Push Notification to it:

....

esb.RequestServerVersionValue = new RequestServerVersion();

esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;

// Create a new subscription.

SubscribeType subscribeRequest = new SubscribeType();

PushSubscriptionRequestType pushSubscription = new PushSubscriptionRequestType();

// Subscribe to events

BaseFolderIdType[] folders = new BaseFolderIdType[1];

FolderIdType folderId = new FolderIdType();

folderId.Id = "AQEuAAADGkRzkKpmEc2byACqAC/EWgMAb/AGiBJ310+gk0Ag9Tmv/QAAAQ6C+wAAAA==";

folders[0] = folderId;

pushSubscription.FolderIds = folders;

.....

I get the error with the message, that the object was not found in the informationmemory.

Well, I got the ID using this sample:

http://groups.google.com.au/group/microsoft.public.exchange.development/browse_thread/thread/b31bda50451a770c/df5a3c2d6fb5313a

Can you please help me?

Christian

# October 1, 2008 5:04 AM

Christian said:

Hi Vikas,

my problem is solved!

Thank you.

Do you know how to get the SMTP-Header from a eMail?

Christian

# October 1, 2008 8:27 AM

Christian said:

Hi Vikas,

my problem is solved!

Thank you.

Do you know how to get the SMTP-Header from a eMail?

Christian

# October 1, 2008 8:29 AM

Christian said:

Hi,

I have a interesting problem. My subscriber is looking for some public folders to get there ID.

Some of them are found and some not. Well, the search request is the same and in the properties in the Exchange Management Console I can not find any difference between them. Do you have any idea what could be the problem or what are the settings for the public folders to be found by a search request?

Christian

# October 7, 2008 11:06 AM

rsincavage said:

Hi,

We have recently migrated to Exchange 2007 SP1 (108,000 users).. Ad I would liek to start the process to move some integrated applications away from MAPI to EWS. I have posted this question to another previous post in your blog about VBSCRIPT and OOF...

What I am doing: We have a Call Center (Avaya) application that it integrated via MAPI.. What it does is update calling hunt groups based on who is in or in or out of office. I would like to be able to do this via VBScript with EWS.

# October 14, 2008 2:53 AM

Vikas Verma said:

At this point of time you cannot use EWS to set OOF message for other than yourself. This feature *should* be available in next SP release of Exchange 2007.

Till that time you need to stay with MAPI being the only way to Set/Read OOF message for others.

# October 15, 2008 1:45 PM

hazi said:

I would like to find a written example on how to use a echange web service to loop through an inbox and find specific messsages depending on their subject row.

# October 24, 2008 2:46 AM

Vikas Verma said:

Have you checked these samples ?

http://blogs.msdn.com/vikas/archive/2007/11/14/howto-ews-find-all-folders-inside-a-parent-folder-helpful-in-generating-a-folder-tree.aspx

http://blogs.msdn.com/vikas/archive/2007/07/27/howto-getfolder-finditem-restriction-getitem.aspx

All you need to do is first make a FindItem call in the Inbox, and list down all the items that you need. Then using FindFolder you will traverse through each folder inside inbox (recursively) and call the FindItem there after to get there.

Do let me know if you need any clarification

# October 24, 2008 11:07 PM

CStroliaDavis said:

I have been working with EWS for a while now. Thank you for doing so much to provide some information on how to actually work with getting to e-mail folders.

It seems like so much of the information I find out there for EWS is more related to just tasks and calendaring than it is for e-mail, and what I do find for e-mail is more about sending than working with what has already been received. It gets very frustrating at times.

I would definitely like to see more tutorials and documentation on how to do all things e-mail in EWS.

You already have folder traversing and searching, and Mark Taylor has a good example of actually finding email and getting the body and attachments here on msdn:

http://msdn.microsoft.com/en-us/library/bb508824.aspx

But, I am still getting frustrated.

Now I am trying to find out more information on moving and deleting mail items using EWS. Can you help?

# November 26, 2008 4:06 PM

Vikas Verma said:

Calendar, E-mail messages, Meeting requests,Tasks, Contacts all boiled down to BaseItemType and all the below operations can be performed on any of those item.

CreateItem, CopyItem, DeleteItem, FindItem, GetItem, MoveItem, SendItem, UpdateItem

You can find all the operations that you can perform using Exchange Web Services here

http://msdn.microsoft.com/en-us/library/bb409286.aspx

I agree with you that the object model is very complex at this time but it was just a foundation for EWS with the release of Exchange 2007. Trust be there are lots and lots more to come in future.

If you are aware of Client API which will come with next release of Exchange is very easy to use and can do the job of 20-30 lines of code in just single line of code.

Here is the PDC video which might interest you.

http://channel9.msdn.com/pdc2008/BB46/

I would also recommend you to get yourself a copy of Inside Exchange Web Services from MSPress

http://www.microsoft.com/mspress/books/10724.aspx

# November 26, 2008 10:09 PM

saqib123 said:

Hi Vikas,

I am sending a mail using EWS and I am sucessfull in sending the mails.

The problem is once I send a mail and get the temInfoResponseMessageType object from the CreateItemResponse.ResponseMessage object, the ArrayofrealItems object is null and hence I am not able to get the Id and the change key of the newly created e-mail.

Can you please help....?

Regards,

Saqib Mukri,

# December 19, 2008 7:23 AM

Vikas Verma said:

Can you contact me via http://blogs.msdn.com/vikas/contact.aspx page. I would like to have a look at the code and also the response from the server.

# January 9, 2009 9:15 PM

S R said:

Hi

I want to send an email using EWS and I found a sample example of SendItem but it doesnot show any example code but show SOAP messages.

I dont know how to use it.

Please help me.

# February 2, 2009 8:57 PM

Alan said:

HI Vikas,

Thanks for the great information you've posted.  I'm trying to read the notes field in a contact and I can't seem to find it. Can you point me in the right direction?

Alan

# February 28, 2009 6:47 PM

Vikas Verma said:

^^ SR ^^ - You need to call CreateItem with disposition as SendAndSaveCopy (to send an email and store a copy in send items)

Here is the sample code

http://msdn.microsoft.com/en-us/library/exchangewebservices.createitemtype.aspx

I would recommend you to get a copy of Inside Exchange Web Services from MSPress to get started.

# February 28, 2009 7:02 PM

Vikas Verma said:

^^ Alan ^^ - The Body is actually the notes field. You can read the Body field of ContactItemType to get/set the notes field. Hope that helps.

# February 28, 2009 7:13 PM

James T. said:

I'm trying to send a email with an attachment.  I can't figure it out.  The couple examples I found on the net, don't work.  One on codeproject.com looks like it should, but I can't get the ids working.

The example that MSDN comes with to send an email works fine (from CreateItemType class).  I can't figure out how to include the example from the AttachmentType into the CreateItemType example.

# March 2, 2009 11:45 AM

Vikas Verma said:

Hey James,

I will work on that sample and blog it coming week. It should be fairly simple :-)

# March 8, 2009 5:19 PM

Seema said:

Hi,

I have successfully created and sent email messages using CreateItem method of Exchange WebServices. The  response I get back is of type ResponseMessageType and I see that ResponseClass is success.

My requirement is that I need to find out the message id and the exact location/url of the .msg file that was created as a result of CreateItem. How do I get this info? The response message does not give me any info about the message id or .msg file.

Thanks

# March 9, 2009 12:02 PM

Vikas Verma said:

Seema,

You need to cast the ResponseMessageType to ArrayOfRealItemsType and then loop through it to find the ItemId.

This document has a sample code for CreateItem and how to cast the response into MessageType or ItemType

http://msdn.microsoft.com/en-us/library/exchangewebservices.createitemtype.aspx

Once you get the MessageType or ItemType you look for property called ItemId.id which will give you an EWS ItemID.

EWS Item's id is different from the OWA URL or WebDav item ID. But once you get the EWS Item ID you can use the ConvertID method of EWS to convert to PR_EntryID, StoreID, OwaID. OwaId it most probably what you are looking at.

Remember EWS/Exchange/Webdav of nothing store MSG file. MSG file is Outlook specific and once email leave Outlook the message is no longer remain in MSG format. It gets converted to SMTP (rfc822/MIME) format

# March 9, 2009 4:02 PM

Vikas Verma said:

Here is the link to ConvertID method

http://msdn.microsoft.com/en-us/library/bb799665.aspx

# March 9, 2009 4:02 PM

Seema said:

Thanks a lot Vikas. I tried it and it works like a charm. Yes OwaId is what I need currently to get me going. I may have some more questions as I progress with my email application, but I am good for now. Thanks again.

# March 9, 2009 5:41 PM

Seema said:

Hi Vikas,

Is there any way I can pack the content of the message retrieved by the OwaID into a .msg file or any other message file? I understand .msg file is outlook specific but I have provide a link to email message on page and after user clicks on link that email message should load up.

# March 10, 2009 12:29 PM

Waqar Ahmad said:

I am looking to assign a task using EWS, There is way to create but no way to assign and send a task. Can someone help.

# May 19, 2009 4:20 AM

Vikas Verma said:

@Seema.. No you cannot as you understand that's Outlook specific. You should instead look for StoreID & EntryID, with a help of Outlook Add-in you should be able to find the item back in Outlook on the basis of those two IDs.

@Waqar.. You cannot send Task requests using EWS, yet. WebDAV and CDO can be used to send those requests in Exchange 2007. You might see the Task requests supported by next version of EWS

# June 8, 2009 10:53 PM

Buddhi Danajaya said:

I have a application which talks to exchange 2000 and downloads attachments on mail (only for a given mail account). It uses XML "ServerXMLHTTP60Class" for talking and getting mails from Exchange 2000

Q: Can I use same to get mails from Exchange 2007 ? I tried and it is giving "Login Timeout"

(I can pass u sample code which I use with Ex. 2000)

I saw your samples which deals with Attachments on Exchange 2007, they looks great !!!

Q: Which name space I can use for "ExchangeServiceBinding" this ? (I am developing application in a environment, where I don't have a Exchange 2007 server. Is it possible ?)

- Buddhi -

# June 24, 2009 1:32 AM

Vikas Verma said:

Hey Buddhi,

I believe you are using WebDAV at present to download the attachments from your Exchange 2000 server and which is still supported in 2007 but not recommended.

WebDAV will not be available in next release of Exchange so if you want to future proof your application then it's high time you migrate to EWS.

"HTTP 440 - Login Timeout" is most likely because of your server configuration, please see if you have FBA (Form Based Authentication) enabled on the Exchange 2007 server or the same authentication that you are using on Exchange 2000.

Coming to the namespace, then you need to add a Web Service Reference for EWS Web Service and it will add all the EWS object/classes into your project.

You do not need a Exchange 2007 sitting in your local premises or environment, but certainly you need an Exchange 2007 server to communicate to an Exchange 2007 server =).

EWS is understood only by Exchange 2007 and above versions, prior version will not be able to understand the query.

Regards,

Vikas

# June 24, 2009 10:10 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker