Robotic Process Automation (RPA)

 View Only
  • 1.  Send Email

    Posted Mon March 22, 2021 01:45 PM
    Hi,

    I have an issue when I trying to attach a file in a sendemail command when the file is with a dynamic name.
    For example:
    I create an excel file with the name "example-$currentdate.xls".
    After that, I need to send this file as an attachment but the Attachments parameter is a list where I need to put the full path to the file and the variables are not acceptable.

    Could you help me with a solution or advice?

    ------------------------------
    Stanislav Terziev
    ------------------------------


  • 2.  RE: Send Email

    Posted Tue March 23, 2021 05:49 AM
    Edited by NIGEL CROWTHER Tue March 23, 2021 05:49 AM
    Hi Stanislav,

    example-$currentdate.xls

    Does not look right.  Shouldn't it be

    example-${currentdate}.xls  ?

    If I misunderstand, can you paste in the code that does not work and I will take a look

    ------------------------------
    NIGEL CROWTHER
    ------------------------------



  • 3.  RE: Send Email

    Posted Tue March 23, 2021 08:12 AM
    I think it is the way you are defining the variables.  It works for me:

    defVar --name emailServerConnectionInstance --type EmailConnection
    defVar --name in_vaultName --type String --parameter
    defVar --name emailUsername --type String
    defVar --name emailPassword --type SecureString
    defVar --name vaultSuccess --type Boolean
    defVar --name in_recipients --type List --innertype String --parameter
    defVar --name in_subject --type String --parameter
    defVar --name in_body --type String --parameter
    defVar --name in_attachments --type List --innertype String --parameter
    getVaultItem --name "${in_vaultName}" --system  vaultSuccess=success emailUsername=userName emailPassword=password
    logMessage --message "user - ${emailUsername}\r\nrecipients - ${in_recipients}\r\nsubject - ${in_subject}\r\nbody - ${in_body}\r\nattachments - ${in_attachments}" --type "Info"
    imapConnect --mailhost "imap.gmail.com" --mailport 993 --usessl  --UseConnectionToSend  --smtpcredentials  --smtphost "smtp.gmail.com" --smtpport 587 --smtpusername "${emailUsername}" --smtppassword "${emailPassword}" --smtpusessl  --username "${emailUsername}" --mailusername "${emailUsername}" --mailpassword "${emailPassword}" emailServerConnectionInstance=value
    emailSend --connection ${emailServerConnectionInstance} --to ${in_recipients} --from "${emailUsername}" --subject "${in_subject}" --bodytype "Text" --body "${in_body}" --attachments ${in_attachments}

    ------------------------------
    NIGEL CROWTHER
    ------------------------------



  • 4.  RE: Send Email

    Posted Tue March 23, 2021 09:28 AM
    Hi Nigel,
    Thank you for your appreciated support. I looked again my code and your solution and I found the right solution that works for me. Here is the code:

    defVar --name vCurrentDate --type DateTime
    defVar --name vDateText --type String
    defVar --name vFileDownload --type String
    defVar --name vMailConnection --type EmailConnection
    defVar --name vAlsoMail --type List --innertype String --value "[example@example.com"
    defVar --name vAttachmentFile --type List --innertype String --value "[${vFileDownload]"
    getCurrentDateAndTime --localorutc "LocalTime" vCurrentDate=value
    dateTimeToText --date "${vCurrentDate}" --standardformat "SortableDateTime" vDateText=value
    smtpConnect --smtphost "mail.example.com" --smtpport 25 vMailConnection=value
    setVar --name "${vAttachmentFile}" --value "[${vFileDownload}]"
    emailSend --connection ${vMailConnection} --to ${vAlsoMail} --from "example@example.com" --subject "Example - ${vDateText}" --bodytype "Html" --body "Example" --attachments ${vAttachmentFile}

    Thank you again,

    ------------------------------
    Stanislav Terziev
    ------------------------------