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
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.
it appears not possible any more…
Bing search “Is there a VB script that works with the new outlook?”
Result:
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:
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,
So, we will have to go in another direction?
What i am trying to achieve.
Generate the body in HTML format. (Clarion process)
Generate the quote.pdf for the attachment. (Clarion Process)
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.