Forum Discussion

MichaelTamoush's avatar
MichaelTamoush
Qrew Captain
4 years ago

Help with creating email syntax

I have the following code and it works fine, but if I remove the cc: line, it does not work.

Working Code:

var text Subject =
"Subject Text" ;

var text Body =
URLEncode("Body Text");

var text Email = "mailto:[email protected]" &
& "[email protected]"
& "&subject=" & URLEncode($Subject)
& "&body=" & $Body;

"<a href="
& $Email
& ">" & "Create Email" & "</a>"

However, if I comment out the cc line, it doesn't know the next line is the subject, and then the body. It will just string together the subject and body and treat it like another 'To' email address.

What syntax am I supposed to add or change when removing the cc? I am using a formula rich text field.

------------------------------
Michael Tamoush
------------------------------

4 Replies

  • The ? indicates the start of the rest of the parameters after this "mailto:[email protected]

    so, if you remove that cc line then you need to retain the "?"
    For example 

    var text Email = "mailto:[email protected]" &
    //& "?cc=[email protected]"
    & "?subject=" & URLEncode($Subject) // include the ? delimiter here
    & "&body=" & $Body;

    "<a href="
    & $Email
    & ">" & "Create Email" & "</a>"


    ------------------------------
    Mark Shnier (YQC)
    [email protected]
    ------------------------------
    • MichaelTamoush's avatar
      MichaelTamoush
      Qrew Captain
      I thought that may be the case, but when I try that it simply leaves the subject blank. I tried to simplify and test, but same result. Below results in the to field correct, and the Body correct, but the subject blank.

      vvar text Email = "mailto:[email protected]"
      & "?&subject=test"
      & "&body=Body";

      "<a href="
      & $Email
      & ">" & "Create Email" & "</a>"

      ------------------------------
      Michael Tamoush
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        & "?subject=test"
        I think you need to get rid of the & before the word subject.


        ------------------------------
        Mark Shnier (YQC)
        [email protected]
        ------------------------------