locked
VBA CDO.Message RRS feed

  • Question

  • Hi,

    Is there a way to show a mail message generated with CDO in the default email client before sending it?

    Like .Display for Outlook (but is not an object in CDO)

    Thanks,

    Connie

    Thursday, July 21, 2016 5:33 PM

Answers

  • Hi Connie,

    >> Is there a way to show a mail message generated with CDO in the default email client before sending it?

    If you want to create and show the message, could you share us why do you not create email with the email client like outlook? In my option, if you have Outlook installed, I would suggest you create mail with Outlook, and display it with something like below:

    Sub CreateHTMLMail() 
     'Creates a new e-mail item and modifies its properties  
     Dim objMail As Outlook.MailItem
     'Create e-mail item  
     Set objMail = Application.CreateItem(olMailItem)  
     With objMail  
     'Set body format to HTML  
     .BodyFormat = olFormatHTML  
     .HTMLBody = "<HTML><H2>The body of this message will appear in HTML.</H2><BODY> Please enter the message text here. </BODY></HTML>"  
     .Display  
     End With  
    End Sub

    CDO is a library to send email without any mail client installed, and as you have known, there is no object in CDO to display email. If you insist on creating with CDO, and show it with outlook, I think you need to save the message to file with ADODB.Stream, convert eml file to msg file, and use Outlook to open it. This way is much complex, and I would suggest you use Outlook to create and show it directly.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Saturday, July 23, 2016 6:08 AM