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
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