none
How to get message show in outbox? RRS feed

  • Question

  • Back in the days of cdo, I was able to save a message in outbox folder of outlook and then from there they go out. This was very helpful if when exchange service isnt available, you still have messages sitting in outbox and as soon as service restored, the mails would go out.

    How can I achieve same thing with EWS?

    Friday, April 21, 2017 3:35 PM

Answers

  • >> How can I achieve same thing with EWS?

    You can't EWS access the Exchange server directly so if the server isn't available you would need to implement you own offline mechanism, CDO 1.2 would have been using MAPI which give you access to MAPI's offline profile and synchronization ability.

    Cheers
    Glen

    • Marked as answer by Me.Saqib Saturday, June 3, 2017 6:05 PM
    Monday, April 24, 2017 2:20 AM
  • >>Great explanation. So why people would prefer to work with EWS and not with Outlook since it already support many features out of the box such as offline issue etc?

    Outlook is a client application where EWS is an Server Side API so your not comparing apples to apples, there are third party library like Redemption that will work with the new version of Exchange and Outlook which will allow you to keep working CDO like code.

    If you save the Message as a MIME message that would probably be the most flexible format as it will contain the attachments, when you want to send it later you can just submit the MIME content.

    Cheers
    Glen

    • Marked as answer by Me.Saqib Saturday, June 3, 2017 6:06 PM
    Thursday, April 27, 2017 12:34 AM

All replies

  • >> How can I achieve same thing with EWS?

    You can't EWS access the Exchange server directly so if the server isn't available you would need to implement you own offline mechanism, CDO 1.2 would have been using MAPI which give you access to MAPI's offline profile and synchronization ability.

    Cheers
    Glen

    • Marked as answer by Me.Saqib Saturday, June 3, 2017 6:05 PM
    Monday, April 24, 2017 2:20 AM
  • Glen, 

    Thanks for your reply. How should I implement offline mechanism? Do u have any suggestions? Any online samples.... It is very strange that EWS doesnt give any support for offline. 

    The only thing I can think to save the message object in some place (not sure where) and then pick up the messages when the connection is restored.


    Monday, April 24, 2017 2:58 PM
  • >>It is very strange that EWS doesnt give any support for offline

    EWS is a Web Service that runs on the Exchange server so it logically can't provide this, CDO/MAPI/ActiveSync doesn't provide it either its the Outlook application that provided the offline ability. When your using EWS whatever code your using is the client in this instance

    >> The only thing I can think to save the message object in some place (not sure where) and then pick up the messages when the connection is restored.

    You need to implement something that checks connectivity/available of EWS, and maybe de-serialize the object to file until your ready to send. I've not seen any samples for this but its not particular hard, although like anything time consuming to build out and test fully.

    Tuesday, April 25, 2017 7:07 AM
  • Great explanation. So why people would prefer to work with EWS and not with Outlook since it already support many features out of the box such as offline issue etc?

    Regarding de-serialize, my message object has attachments and then I would need to save attachments and probably give them some messageID and upon connection restored, put together the whole message and send again and then delete the attachments .... sound right?

    Tuesday, April 25, 2017 3:47 PM
  • >>Great explanation. So why people would prefer to work with EWS and not with Outlook since it already support many features out of the box such as offline issue etc?

    Outlook is a client application where EWS is an Server Side API so your not comparing apples to apples, there are third party library like Redemption that will work with the new version of Exchange and Outlook which will allow you to keep working CDO like code.

    If you save the Message as a MIME message that would probably be the most flexible format as it will contain the attachments, when you want to send it later you can just submit the MIME content.

    Cheers
    Glen

    • Marked as answer by Me.Saqib Saturday, June 3, 2017 6:06 PM
    Thursday, April 27, 2017 12:34 AM
  • Glen,

    While researching I also found a sample to send an email using outlook library. I tested how it behaves by unplugging network and I found that mail was sitting in the Outbox folder. When I plugged network back again, the mail automatically went out.

    What your thoughts on this?

    private void CreateMailItem()
            {
                Outlook.MailItem mailItem = (Outlook.MailItem)
                    this.Application.CreateItem(Outlook.OlItemType.olMailItem);
                mailItem.Subject = "This is the subject";
                mailItem.To = "someone@example.com";
                mailItem.Body = "This is the message.";
                mailItem.Importance = Outlook.OlImportance.olImportanceLow;
                mailItem.Display(false);
            }

    Thursday, April 27, 2017 10:52 PM
  • The OOM generally requires you have Outlook open to use it but if that is okay for you then it should work okay

    Cheers
    Glen

    Friday, April 28, 2017 2:35 AM
  • Glen, 

    Quick question - I was developing application on my machine and I have outlook 2013 installed. But now our production machine will have outlook 2010 since it is 32 bit machine and we couldnt put 2013 on it.

    So now do I have to compile my app on machine where outlook 2010 is installed or will it work with the current references I have already there.

    These are current references in my proj:

    Friday, May 19, 2017 3:45 PM
  • >>  32 bit machine and we couldnt put 2013 on it.

    Whoever is telling you this is wrong you can install the 32 bit version of Office 2013.

    There are differences between the OOM in each version of Outlook so I would suggest you need to do regression testing if your going to use this on Outlook 2010. The rule of thumb is to build and test against each version you wish to use your code against as https://blogs.msdn.microsoft.com/andreww/2007/06/16/can-you-build-one-add-in-for-multiple-versions-of-office/

    Cheers
    Glen

    Monday, May 22, 2017 4:41 AM
  • Hi Glen,

    I have section of code to check if outlook is already running then use existing session instead of creating of new one. It works fine if the outlook is really open by a user but if the outlook is opened by my App (after sending first email) then it shows up in taskbar with little asterisk symbol and then eventually it exits out but for my app, it is still outlook.exe running when i try to send second email. This is the error message: 

    operation unavailable (exception from hresult: 0x800401e3 (mk_e_unavailable)) outlook

    Upon googling, people said I m running VS not in admin mode but even I run it is in admin mode, I still get error. I build my exe and run from it and still get same error. I have also changed outlook exe properties to run as administrator under Compatibility tab but no help.

    This is the code  that fails:

    If Process.GetProcessesByName("OUTLOOK").Count > 0 Then
          _outlookApp = DirectCast(Marshal.GetActiveObject("Outlook.Application.14"), Outlook.Application)

    Monday, May 29, 2017 11:51 PM
  • Outlook (or any of the office suite) aren't really built for unattended Automation (I've had simular problems using Excel) this isn't really the right forum to ask that type of question you may have more luck in other forums if your after a workaround. Personally I would use Redemption http://www.dimastr.com/redemption/rdo_introduction.htm for unattended Server side Automation in MAPI where I couldn't use EWS (which is pretty rare).
    Wednesday, May 31, 2017 6:17 AM