Send On Behalf of Outlook Operation

KPrasanth9

New Member
Hi Team,

I am trying to implement Send On Behalf of Outlook functionality in my process when am implementing that I came across a code which will resolve my issue

Resolving Code:
var application = new Application();
var mail = (_MailItem) application.CreateItem(OlItemType.olMailItem);
mail.To = "anonymous@somedomain.com";
....
Outlook.Account account = Application.Session.Accounts["MyOtherAccount"];
mailItem.SendUsingAccount = account;
mail.Send();

I Tried to append the same at required places in my code and am unable to get a resolution for this, by default the outlook profile parameter is set to Outlook i have created another profile called prasanth.kolla99@outlook.com and tried to implement the Send Email action in Outlook VBO still it's throwing exception which am unable to understand, please help me in resolving the issue also let me know if there is any way to get a Visual Basic Compiler to the code which am using in Blue Prism or any one already have a code for this if so please help me in resolving the issue with the code you used.

** Note : Please copy paste this code in Outlook VBO in send email code stage
>
Dim app = CreateObject("Outlook.Application")
Dim mail = app.CreateItem(0)
Dim addressCount As Integer

If To <> "" Then
Dim toAddresses = Split([To], ";")
For addressCount = LBound(toAddresses) To UBound(toAddresses)
Dim recipient = mail.Recipients.Add(toAddresses(addressCount))
recipient.Resolve
If recipient.Resolved Then recipient.Type = OlMailRecipientType.olTo
Next

End if

If CC <> "" Then
Dim ccAddresses = Split([CC], ";")
addressCount = 0
For addressCount = LBound(ccAddresses) To UBound(ccAddresses)
Dim recipient = mail.Recipients.Add(ccAddresses(addressCount))
recipient.Resolve
If recipient.Resolved Then recipient.Type = OlMailRecipientType.olCC
Next

End If

If BCC <> "" Then
Dim bccAddresses = Split([BCC], ";")
addressCount = 0
For addressCount = LBound(bccAddresses) To UBound(bccAddresses)
Dim recipient = mail.Recipients.Add(bccAddresses(addressCount))
recipient.Resolve
If recipient.Resolved Then recipient.Type = OlMailRecipientType.olBCC
Next

End If

mail.Subject = Subject
mail.HTMLBody = Message

For Each att As String In Attachments.Split(";"c)
If att = "" Then Continue For
mail.Attachments.Add(att)
Next
//Code appended start
mail.sendUsingAccount = app.Session.Accounts.Item("prasanth.kolla99@outlook.com")
//Code Ended
mail.Save
mail.Send




#Attaching the Outlook Object i have used Send Mail action for my process by modifying few things

Regards,
Prasanth
 

VJR

Well-Known Member
What happens when you use the below in the second code you have pasted.
mail.SentOnBehalfOfName = "Emailaddress"
 

Jan Čech

New Member
Hi I have resolved this problem few month ago.

Setting has 2 parts, in MS Outlook and of course in Blue Prism Object Libary. See in attach files how to define action in object libary of Blue Prism and also how to set MS Outlook.

Important: To input param "FROM" write email address you want to send on behalf (full adres with @ and domain), NOT mailbox name of mailbox you used for sending on behalf.
 

Attachments

  • code.txt
    818 bytes · Views: 72
  • inputs.GIF
    46.7 KB · Views: 65
  • outputs.GIF
    40.6 KB · Views: 58
  • process.GIF
    3.8 KB · Views: 57
  • HOW TO SET OUTLOOK FOR USING SENDING EMAIL ON BEHALF.pdf
    334.9 KB · Views: 69
Top