Formatted text for email

I'd like to explore creating an email for a condition or many conditions depending what the email is going to relay. I'd like to create a formatted text with multiple lines with spacing. I learn by example and wonder if anyone can share something they started?

Thanks in advance

Comments

  • Has anyone emailed from Eggplant?
  • EggplantMattEggplantMatt ForumAdmin admin
    If you're looking for a response from the community, then it's appropriate to post here. For support issues, please email Eggplant technical support directly..
  • I am able to email from Eggplant but asking the community if they have sent a multi line email and how they formatted it? Looking for ideas relay info to someone that needs to know the result or what is waiting to happen. We are trying to alert that something needs to happen(waiting for interfaces) to continue the next steps.
  • DaveHesterDaveHester Member ✭✭
    Hope that this following helps.
    Dave
  • DaveHesterDaveHester Member ✭✭
    edited January 16
    Script requires the following code to be place inside test script

    RunWithNewResults ScriptName
    put the result into TestResult

    Sends an email from within a script and closes

    If global ScriptOwner is empty then
        put "[email protected]" into global ScriptOwner
    End If
    set MailHost to "mailserver.domain.com"
    set MailAuthentication to "Login"
    set MailUser to "[email protected]"
    set MailPassword to "password"
    set MailType to "text/html"
    put global TestResult.Duration div 60 into TestDurationInMinutes
    put global TestResult.Duration rem 60 into TestDurationInSeconds
    put format ("%02i",TestDurationInSeconds) into TestDurationInSeconds
    put TestDurationInMinutes&":"&TestDurationInSeconds into TestDuration
    put global TestResult.LogFile into ScreenError
    replace "logfile.txt" with "screen_error.png" in ScreenError
    put "<table>" into MailBody
    put "<tr><td>Duration:</td><td>"&&TestDuration&&"</td></tr>" after MailBody
    put "<tr><td>Errors:</td><td>"&&global TestResult.Errors&&"</td></tr>" after MailBody
    put "<tr><td>Exceptions:</td><td>"&&global TestResult.Exceptions&&"</td></tr>" after MailBody
    put "<tr><td>Log File Location:</td><td>"&&global TestResult.LogFile&&"</td></tr>" after MailBody
    put "<tr><td>Run Date/Time:</td><td>"&&global TestResult.RunDate&&"</td></tr>" after MailBody
    put "<tr><td>Status:</td><td>"&&global TestResult.Status&&"</td></tr>" after MailBody
    put "<tr><td>Warnings:</td><td>"&&global TestResult.Warnings&&"</td></tr>" after MailBody
    set Recipient to global ScriptOwner
    set Title to "Parameterized email test"
    If global TestResult's Status is "success" then
        set Title to "SUCCESS - Test:"&&global TestName
        sendMail (To:Recipient,\
        Subject:Title,\
                SMTP_HOST:MailHost,\
                SMTP_TYPE:MailAuthentication,\
                SMTP_USER:MailUser,\
                SMTP_PASSWORD:MailPassword,\
                "Content-Type":MailType,\
                Body: MailBody,\
                Attachment: global TestResult.LogFile)
    Else
        set Title to "FAILURE - Test"&&global TestName
        sendMail (To:Recipient,\
        Subject:Title,\
                SMTP_HOST:MailHost,\
                SMTP_TYPE:MailAuthentication,\
                SMTP_USER:MailUser,\
                SMTP_PASSWORD:MailPassword,\
                "Content-Type":MailType,\
                Body: MailBody,\
                Attachment: (ScreenError,global TestResult.LogFile))
    End If

  • scoots987scoots987 Member

    Thanks Dave, yes this is very helpful. I've been playing with how to get permission to send emails automatically inside out network. For obvious reasons.

    Thanks,

    Scott

    P.S. - Sorry I didn't see your response until now. I don't know how I missed it.


  • Leann_OlsonLeann_Olson Member
    I can not see Dave's code above, can someone share again?  TIA
  • EggplantMattEggplantMatt ForumAdmin admin
    Not sure what's going on with the code tagging. Removed it so that you can read the post.
  • DaveHesterDaveHester Member ✭✭
    Hi Leann,

    Just let me know if you have any questions around my SendMail script, and I can follow up with you directly.

    Thanks,
    Dave
Sign In or Register to comment.