Blue Prism Product

last person joined: yesterday 

Chat about Blue Prism products
Expand all | Collapse all

MS Outlook VBO

  • 1.  MS Outlook VBO

    Posted 05-22-2019 10:33
    ​Hi,

    I am looking to use the Outlook VBO to send emails as I need to use HTML enabled for the formatting.

    I need to be able to send from a shared mailbox.

    Does anybody have the code required to either amend the 'Send Email' action
    or create a 'Send Email From' action.

    (I can not use the POP3/SMTP object)

    ------------------------------
    Declan Keeton
    RPA Developer
    E.ON
    ------------------------------


  • 2.  RE: MS Outlook VBO

    Posted 05-22-2019 10:44
    Edited by Ami Barrett 08-04-2020 16:17

    Edit: Redoing this post, because I initially misread the query. (Thank you BP, for finally allowing edits!)

    Just before the mail.save and mail.send lines, add this:

    Inputs:

    [SendFrom] - Text

    Code:

    if SendFrom <> Nothing
    	mail.SentOnBehalfOfName = SendFrom
    end if​


  • 3.  RE: MS Outlook VBO

    Posted 05-23-2019 04:08

    ​Hi Ami,

    Thanks to the forums for the edits as much happier with the edited than the original reply!

    This worked perfectly and was quick to implement.

    Thanks mate!



    ------------------------------
    Declan Keeton
    RPA Developer
    E.ON
    ------------------------------



  • 4.  RE: MS Outlook VBO

    Posted 09-20-2019 02:27
    Edited by Andre Köpplin 08-04-2020 16:15
    Hello Ami

    I saw, that you support Declan by an issue with Outlook and Sent E-Mails on Behalf. I have the problem, that I cant sent E-Mails on behalf with this code from a shared mailbox. Maybe you can give me an hint, what I am doing wrongly​? Secondly, I am also not got the output that thee E-Mail was sent.

    Dim oApp As Microsoft.Office.Interop.Outlook._Application
    oApp = New Microsoft.Office.Interop.Outlook.Application
    Dim myItem As Microsoft.Office.Interop.Outlook.MailItem

    try
     myItem = oApp.CreateItemFromTemplate(templatePath)
    myItem.From = FromAddress
     myItem.To = mailAddress
     myItem.Subject = myItem.Subject _
         .Replace("<Name>", firstName) _
         .Replace("<Surname>", lastName)
     myItem.HTMLBody = myItem.HTMLBody _
      .Replace( _
       "<span style='background:silver;mso-highlight:silver'>Ms. X</span> / <span style='background:silver;mso-highlight:silver'>Mr. Y</span>", firstLine) _
      .Replace( _
       "<span style='background:silver;mso-highlight:silver'>Sehr geehrte Frau X</span> / <span style='background:silver;mso-highlight:silver'>Sehr geehrter Herr Y</span>", firstLine) _
      .Replace( _
       "<span lang=FR style='mso-bidi-font-family:""xxxx Type Light"";background:lightgrey;mso-highlight:lightgrey;mso-ansi-language:FR'>Madame </span><span lang=FR style='mso-bidi-font-family:""XXXX Type Light"";mso-ansi-language:FR'>, / <span style='background:lightgrey;mso-highlight:lightgrey'>Monsieur</span>,</span>", firstLine) _
      .Replace( _
       "<span lang=IT style='mso-bidi-font-family:""xxxx Type Light"";background:lightgrey;mso-highlight:lightgrey;mso-ansi-language:IT'>Gentile signora X</span><span lang=IT style='mso-bidi-font-family:""xxxx Type Light"";mso-ansi-language:IT'> / <span style='background:lightgrey;mso-highlight:lightgrey'>Egregio signor Y</span></span>", firstLine)

     If(itMailInside.Length > 1)
      myItem.HTMLBody = myItem.HTMLBody _
      .Replace( _
       "<span style='background:lightgrey;mso-highlight:lightgrey'>tenuta</span> / <span style='background:lightgrey;mso-highlight:lightgrey'>tenuto</span>", itMailInside)
     End If

     myItem.Send()
     mailSent = True
     mailSent = False
     If myItem Is Nothing
     Else
      myItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard)
     End If
    Catch ex as Exception

    End try

    ------------------------------
    Andre Koepplin
    Business Process Analyst
    Wroclaw
    ------------------------------



  • 5.  RE: MS Outlook VBO

    Posted 09-23-2019 13:33
    Edited by Ami Barrett 08-04-2020 16:20
    Instead of myItem.From, try myItem.SentOnBehalfOfName .

    ------------------------------
    Ami Barrett
    Lead RPA Software Developer
    Solai & Cameron
    America/Chicago
    ------------------------------



  • 6.  RE: MS Outlook VBO

    Posted 29 days ago
    Hi Ami - thanks for this, it worked for me too which is great and helped me resolve an urgent issue! I was wondering, is there a way to get confirmation that the email did actually send? I inputted an address incorrectly and the action completed fine but it was not actually received but it wasn't flagged at all within BP as an exception or an error?

    ------------------------------
    Sophie Katherine Smith
    HR Systems, Data and Quality Assurance Manager
    Arup
    Europe/London
    ------------------------------



  • 7.  RE: MS Outlook VBO

    Posted 29 days ago
    Edited by Ami Barrett 29 days ago
    Hey, Sophie - 
    Typically, if an invalid address is specified, Outlook will still successfully send the message. In cases like this, the postmaster/daemon would handle the invalid recipient and send back a message stating that the destination would be invalid. I would think the only way to validate programmatically, is to check for a bounced e-mail in the inbox.

    ------------------------------
    Ami Barrett
    Sr Product Consultant
    Blue Prism
    Plano, TX
    ------------------------------



  • 8.  RE: MS Outlook VBO

    Posted 29 days ago
    ah ok yes good point - thanks!

    ------------------------------
    Sophie Katherine Smith
    HR Systems, Data and Quality Assurance Manager
    Arup
    Europe/London
    ------------------------------