none
Get Email Message after send it with Exchange Library RRS feed

  • Question

  • Hi, I have developed a Sharepoint 2010 web part to send new emails, that use the Exchange Web Services. The problem that I'm having is that after I send the email, I need to attach that email in a .eml format file into a Sharepoint List.

    But I'm not able to get the ID of email so I can recover it and save it in that format.

    I create the email variables as:

    Dim Email as EmailMessage

    Then I sended it with the function

     

    Email.SendAndSaveCopy(WellKnownFolderName.SentItems)

     

    After this line, I try to get the Id of the mail with Email.ID, but it return nothing.

    So I want to know if there is a way to get the email Id  or there is a way to make the .eml file after save it.

     

    Thanks!!!!

     


    Tuesday, October 18, 2011 9:05 PM

Answers

  • You can't call the Save method more then once eg when you call Save the first time the Item will be created in the Exchane Store and the ItemId would be returned. Any further changes to the Item you should call update if your trying to move the Item to another folder eg from the Drafts to the SentItems folder you use the Move method instead. If thats not what is happening it would help to see more your code to see what your trying.

    Cheers
    Glen 

    • Marked as answer by JulianPascual Tuesday, May 29, 2012 8:34 PM
    Thursday, October 20, 2011 12:35 AM

All replies

  • The easiest way to do it is call save first and then use the Send method rather then SendAndSaveCopy which has problems anyway if your trying to send attachments as well. When you call the save method the Id property will then be populated and calling send will mark the message sent as per you would see in Outlook.

    Cheers

    Glen 

    Wednesday, October 19, 2011 2:27 AM
  • Thanks you so much!! I put that and I could get the Id. But the problem If that the email will contains attachments, so when i put:

    Message.Save(WellKnownFolderName.SentItems)

    I get this error: "This operation can't be performed because this service object already has an ID. To update this service object, use the Update() method instead."

    Do you know how to resolve this?

     

    Thanks!

    Wednesday, October 19, 2011 2:12 PM
  • You can't call the Save method more then once eg when you call Save the first time the Item will be created in the Exchane Store and the ItemId would be returned. Any further changes to the Item you should call update if your trying to move the Item to another folder eg from the Drafts to the SentItems folder you use the Move method instead. If thats not what is happening it would help to see more your code to see what your trying.

    Cheers
    Glen 

    • Marked as answer by JulianPascual Tuesday, May 29, 2012 8:34 PM
    Thursday, October 20, 2011 12:35 AM