winapioutlookoleoffice-automationnew-outlook

How to send an email with an attachment via outlook programmatically?


My app starts an outlook and send an email with an attachment. My new pc has a different version of outlook, The version is 1.2023.1018.300 (Production). Client Version is 20231013005.12 .

My app get an error with the new outlook. The error message is "Invalid class string".

The error is from starting an outlook process by using ole.

     ``` Outlook:=CreateOleObject('Outlook.Application') ;``` 

I guess the new outlook has a different name.

I tried using ShellExecute as well. This way launches outlook without error, but it doesn't have an attachment in the email.

``` ShellExecute(handle, "open", em_mail, NULL, NULL, SW_SHOWNORMAL);``` 

The em_mail is 'mailto:' & recipient_email_address & '?subject=' & subject & '&body=' & body & '&attachment=' & attachment_path;

Thanks for your help.

Peter


Solution

  • The new Outlook (Monarch) does not have the same COM API as the desktop Outlook. It does not have any API besides Web addins (JS).