Microsoft Outlook default signature

Hi all,

For sending emails from my Clarion app I use an OLE control with a piece of VB script. This works fine, but the default (MS Outlook) signature in the body is missing. I read on stack overflow that this will be placed in the body. But not tin my case. I may be missing perhaps one line of code to fill the body with the preferred signature from Outlook.

Does anyone have a suggestion?

VB script:

?OleOutlook{'Application.Visible'} = True
?OleOutlook{PROP:Create}='outlook.application'
OutMail=?OleOutlook{'createItem(0)'}
IF OutMail[1]<>'`'
    MESSAGE('Cannot send a message by Microsoft Outlook.','Error',ICON:Hand)
ELSE
    ?OleOutlook{OutMail&'.Subject'} = 'Your invoice 123456'
    ?OleOutlook{OutMail&'.To'} = '[email protected]'
    ?OleOutlook{OutMail&'.HTMLbody'} =  ??????
    ?OleOutlook{OutMail&'.Attachments.Add('&Invoice123456.PDF&')'} 
    ?OleOutlook{OutMail&'.Display'}
END
?OleOutlook{'Application.Display'} = True
?OleOutlook{'Application.Visible'} = True

Regards,

Henk Ouwejan

Hi Henk,

I asked ChatGPT, and it suggested that the issue might be due to how the Outlook Object Model handles signatures. When setting the HTMLBody or Body property, Outlook replaces the entire email content, including the signature. Obviously GPT has also been known to be wrong.

Below is the adjusted code incorporating the suggestion to include the signature by appending custom content to the existing body:

?OleOutlook{'Application.Visible'} = True
?OleOutlook{PROP:Create} = 'outlook.application'
OutMail = ?OleOutlook{'createItem(0)'}
IF OutMail[1] <> '`'
    MESSAGE('Cannot send a message by Microsoft Outlook.', 'Error', ICON:Hand)
ELSE
    ExistingBody = ?OleOutlook{OutMail & '.HTMLBody'}  ! Retrieve the existing content, which includes the signature
    IF LEN(ExistingBody) = 0
        MESSAGE('Default signature not found.', 'Warning', ICON:Exclamation)
    END

    NewContent = '<p>Your invoice 123456</p>'  ! Add your custom content here
    ?OleOutlook{OutMail & '.Subject'} = 'Your invoice 123456'
    ?OleOutlook{OutMail & '.To'} = '[email protected]'
    ?OleOutlook{OutMail & '.HTMLBody'} = NewContent & ExistingBody  ! Append your content to the signature
    ?OleOutlook{OutMail & '.Attachments.Add(' & Invoice123456.PDF & ')'}
    ?OleOutlook{OutMail & '.Display'}
END
?OleOutlook{'Application.Display'} = True
?OleOutlook{'Application.Visible'} = True

Tip for Posting Code on the Forum:
When posting clarion code on the forum, you can format it for better readability by wrapping it with three backticks ``` followed by the word clarion at the start and three backticks at the end. For example:
```clarion
! Your Clarion code here
``` becomes.

! Your Clarion code here

Mark

1 Like

Hello Mark,

Thank you for the tip for displaying readable Clarion code (much better :slight_smile: )

The HTMLBody was still empty. The third ChatGPT solution I got (ChatGTP is my new friend) this:

! Add signature (Outlook will do this for you)
?OleOutlook{OutMail&'.Display'}

This code must before: ExistingBody =

And now it works

Hi Henk,
Does this/your ole script work with the NEW Outlook?

I have been using a VBS script for years, But the New Outlook does not respond to it.

F

it appears not possible any more…
Bing search “Is there a VB script that works with the new outlook?”
Result: :worried:

Unfortunately, the new Outlook for Windows does not support the Outlook Object Model, which means it cannot be automated using VBScript. This is a significant change from the classic Outlook, where VBScript could be used for automation tasks. Additionally, the new Outlook does not include support for VBA or other developer tools.

If you need automation or scripting capabilities, you might consider the following alternatives:

  1. Microsoft Graph API: This is a modern and robust way to interact with Microsoft 365 services, including Outlook. It allows you to perform tasks like sending emails, managing calendars, and more, but it requires programming knowledge in languages like Python, JavaScript, or C#.

Hmm, :thinking:

So, we will have to go in another direction?
What i am trying to achieve.

  1. Generate the body in HTML format. (Clarion process)
  2. Generate the quote.pdf for the attachment. (Clarion Process)
  3. Click the button to Email. which will formulate the TO, SUBJECT Line, add ATTACHEMENTs and load the BODY-HTML file. (Clarion Process)
    Present /open this NEW EMAIL WINDOW to the user to review before they press SEND.

Any OTHER suggestions?

F

Yes, " Microsoft Graph is the gateway to data and intelligence in Microsoft cloud services like Microsoft Entra and Microsoft 365."