Hello everybody,
I'm currently trying to create and send an email with attachements as a part of an automated process.
The process looks as follows:
How can I adjust this code to use in a code stage in Blue Prism? Is it worth it or is there a better way to accomplish this?
Thanks in advance for your help!
I'm currently trying to create and send an email with attachements as a part of an automated process.
The process looks as follows:
- Receive an email with a specific subject and trigger the BLue Prism process
- Get files from the URL in the email (Excel-files)
- Do some operations to those files
- Send newly created Excel files to specified recipients
Code:
Sub SendMessage(DisplayMsg As Boolean, Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is the body of the message." &vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
For Each ObjOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next
.Save
.Send
End With
Set objOutlook = Nothing
End Sub
How can I adjust this code to use in a code stage in Blue Prism? Is it worth it or is there a better way to accomplish this?
Thanks in advance for your help!