How do I create a button to initiate an email from Outlook?

  • 0
  • 2
  • Question
  • Updated 8 months ago
  • Answered
I would like to create a button to add to a form that would initiate a standard email from Outlook to another QB user. The email should send a copy of, or a link to, the record being displayed in the form when the button is clicked. Is this possible?
Photo of Karen

Karen

  • 222 Points 100 badge 2x thumb

Posted 6 years ago

  • 0
  • 2
Photo of Mark_Shnier

Mark_Shnier

  • 590 Points 500 badge 2x thumb
This is an example of a URL formula field to invoke the user's default mail client.  The are some lines commented out that would turn it into a formula-text field as an href type link.  But in the new UX when you click those on a report the record also opens up, which is most confusing to users.

... Anyways, here is an example.  You should URLEncode anything from a field that might have spaces or special characters.


//"<a href=\

"MailTo:customerservice@gesco.ca"

// the above text invokes the mail client, and creates the TO line

&"?subject=Quick Specials Order"

// the above text does the subject line, below that is the body
// the %0A is a line feed type indicator.

&"&body=Attention SHNIER Customer Service, please order the following for me "
&"%0A%0A"&[Specials List Category - Accessories Group]


&"%0A"& URLEncode([Description])

&"%0A"&"Item Code: " & URLEncode([ITEM#])
&"%0A" & "Price is " & URLEncode([Price & Comment])
& If([Cuts OK?]="OK", " (Price is $1.25 extra for cuts)")
& If([Rolls Only?], " (no cuts allowed on this item)")

&"%0A%0A" & "Qty is " & [Qty Available]  & " U/M is "  & [UM] & "  (Edit Qty as necessary)"

&"%0A%0A" & "My Store name is :"
&"%0A%0A" & "My Tel number is :"
&"%0A%0A" & "My name is :"
&"%0A%0A" & "My Purchase Order is:"
&"%0A%0A" & "My Ship date is:"
&"%0A%0A" & "Special Instructions:"

// OK the URLEncode function is required because putting certain special
// characters into the HTML messed it up.  So, since you can't directly
// put an = or & into the string, you need to use the URLEncode function.

&"%0A%0A" & "(Internal use information follows)"
&"%0A" & "Locn: " & URLEncode([Location])
&"%0A" & "Serial: " & URLEncode([Serial#])
&"%0A" & "Shade: " & URLEncode([Shade])

&"%0A%0A" & "Here is a Query for the Item in Quick Specials"

&"%0A" &"https://gesco.quickbase.com/db/xxxxxxxx?a&quot;
& URLEncode("=")& "q" & URLEncode("&") & "qid"
& URLEncode("=") & "65" & URLEncode("&") & "nv"
& URLEncode("=")  & "1" & URLEncode("&")
& "v0"& URLEncode("=") & "Item" & URLEncode([ITEM#])

 
// This last bit creates the words for the link that you click.

//&"\">"&"<b>Order by Email"&"</a>"
Photo of Sales Info

Sales Info

  • 798 Points 500 badge 2x thumb
Mark_Shnier,

I copied and pasted your code into the URL formula field but the mailto keeps popping up as an error (see below). Can you please help me fix this problem? Thanks!


Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
This works:

// create 3 text variables then execute them in order

// first variable holds the email address & content

var text URLONE = "MailTo:" & URLEncode([EmailAddressFieldName])

&"?subject=TYPE YOUR SUBJECT HERE"

&"&body=TYPE THE BODY OF YOUR EMAIL HERE, IF YOU INCLUDE FIELDS, DO IT LIKE THIS:”

& URLEncode([FieldName])

& "MORE EMAIL BODY UNTIL YOU’RE DONE, THE NEXT BIT IS HOW TO CREATE CARRIAGE RETURNS IN THE EMAIL BODY:"

&"%0A"  // this makes a carriage return

&"%0A";  //make sure to include the semicolon to end the variable declaration statement

 

// this is a little bonus, it checks a box on the record that indicates you’ve sent the email (so you remember not to send it twice)

var text URLTWO = URLRoot()

& "db/"

& Dbid()

& "?act=API_EditRecord&"

& "rid=" & URLEncode([Record ID#])

& "&_fid_91=1"; // this is the checkbox field ID, and you set it to equal 1, which is TRUE or Checked

 

// this re-loads the page when you’re done

var text URLTHREE = URLRoot()

& "db/"

& [_DBID_CAMPAIGNS] // replace with your table ID name

& "?a=dr&rid="

& [Related Campaign]; // id of the table you’re redirecting to (the button on this case was on a child record, therefor the “related” part...

 

// this “runs” the script: checks the box, then reloads the page, then sends the email, in that order

$URLTWO

& "&rdr=" & URLEncode($URLTHREE)

& URLEncode("&rdr=" & URLEncode($URLONE))


Photo of Sales Info

Sales Info

  • 798 Points 500 badge 2x thumb
Michael,

I copied your code and I got a syntax error below. The code seems right to me but not sure why it is not working. I am using formula URL type. Is it a type that I am supposed to use?



Please help. Thanks for the code!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,078 Points 50k badge 2x thumb
@sales info, please do not post code by a screen shot.  no one can read it and its not editable.

If you have a syntax error, post the code by copy and paste of the code, and also post the error message which includes the underlining.
Photo of Sales Info

Sales Info

  • 798 Points 500 badge 2x thumb
Michael,

I created 3 variable called email1, email2, email3. I am having a problem with the second variable. Can you please check my variables below. Also, what Do I need to do next after creating three variables?



The first variable: email1 

var text URLONE = "MailTo:" & URLEncode([Email])

&"?subject=THIS IS A TEST"

&"&body=TYPE THE BODY OF YOUR EMAIL HERE. THIS IS A TEST"
&"%0A"  

&"%0A";

var text URLTWO = URLRoot()

& "db/"

& Dbid()

& "?act=API_EditRecord&"

& "rid=" & URLEncode([Record ID#]) //DO I HAVE TO CHANGE [Record ID#]?

& "&_fid_91=1"; 

The second variable: email2 

var text URLTHREE = URLRoot()

& "db/"

& [_DBID_TICKETS]  // THE TABLE IS CALLED "Tickets"

& "?a=dr&rid=" & [Related Campaign]; // I DON'T GET THIS PART. IS IT THE ID OF THE TICKET table // How do I know the ID number for the tickets table? The third variable: email3

$URLTWO

& "&rdr=" & URLEncode($URLTHREE)

& URLEncode("&rdr=" & URLEncode($URLONE))


After creating three variable above, what am I supposed to do next? How do I create a button on the ticket table?

Please help. Thanks so much!!



Photo of Karen

Karen

  • 222 Points 100 badge 2x thumb
Thank you very much! Was able to figure out 97% of what I need to do :)

Two remaining questions:
1. Is it possible to have QuickBase look at my Program Manager field to get the "To" info for the email?

2. What do I put at the end of the sentence below to create a link back to the record from which the email was initiated?
Please contact me about this record: (this is where I'd like to have a link back to the record)

Thank you again!
Photo of Mark_Shnier

Mark_Shnier

  • 590 Points 500 badge 2x thumb
no problem

Create a Formula email field [Program manager email] with the formula UsertoEmail([program manager]) and include that in the Mailto like

"MailTo:" & URLEncode([Program manager email])

I'm not sure if you need to URLEncode it, but it shouldn't hurt just in case the @ in email addresses is an illegal character.

As for the last part you should be able to simply have a line like

&"%0A%0A" & "Please contact me about this record "
& URLEncode (URLRoot() & "db/" & dbid() & "?a=dr&rid=" & [record ID#])
Photo of Karen

Karen

  • 222 Points 100 badge 2x thumb
THANK YOU, THANK YOU, THANK YOU!!!
That did it! :)
Photo of M

M

  • 80 Points 75 badge 2x thumb
Mark,
how do i embed a form in the email i'm generating? i understand how to embed the form (showing the buttons and fields) in a regular QB notification, but what about this notification that's being generated directly in Outlook?

i've created the button to allow people to "Approve" or "Reject" and tried using the API_Authenticate but i'll have to work on that some more because i'm getting errors. How do i make the hyperlink display in a button like it does within QB???
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
I do not know of a way to send anything other than basic text in a MAILTO: button.  I do not claim to be an expert in MAILTO formatting, but I'm under the belief that the MAILTO is like the lowest common denominator for causing an unknown random "Mail client" to pop up a window.  It could end up being Outlook or a gmail webmail screen or whatever the default mail client is for the random user who clicks that link.  Since the mailto does not know who will be clicking it, its very basic.

My suggestion is to reconsidering using the built in email Notifications and giving the user a way to specify the email addresses and to manually trigger the email.
Photo of M

M

  • 80 Points 75 badge 2x thumb
how do i add an address to the "CC" line? i've tried this:
"MailTo:name@domain.com?cc=othername@domain.com"&
"?subject=test email"

which results in "name@domain.com" going into the "To:" line as needed, but everything else goes into the "cc" line (including the ? before subject=test email.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
Se if this helps.  its just a random google on "mailto syntax", but  think it has your answer. http://www.labnol.org/internet/email/learn-mailto-syntax/6748/
Photo of M

M

  • 80 Points 75 badge 2x thumb
that's a good one, but it doesn't help me with the error i'm getting in the QB formula button.

even when i type:
MailTo:name@domain.com?cc=othername@domain.com?subject=subjectline
in the browser it generates an email that looks like this:

To... name@domain.com
Cc... othername@domain.com?subject=subjectline


i must be missing something between the "othername@domain.com" and the "?subject=..." pieces.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
I played with it and I think that the issue is that there can only be on "?"  Typically the ? means " and here are all the parameters.
try this


"<a href=\"MailTo:"&[Emails for carrier and others separated by semi colons]

// the above text invokes the mail client, and creates the TO line

& "?cc=test@test.com"

&"&subject="
&[Carrier Subject Line] & " for Trailer " & [Trailer / Container #]

// the above text does the subject line, below that is the body
// the %0A is a line feed type indicator.

& "&body=" &[Carrier Body Header]
Photo of M

M

  • 80 Points 75 badge 2x thumb
fantastic. i started copying and pasting like a crazy man and randomly discovered that if i only put the ? before the "cc" and then used "&" for each line of stuff it worked.

thanks so much for your help on this one. i didn't know what the ? meant, but now i do and it makes much more sense.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
Its actually similar to quickbase urls, they define a path and then they always have a  ? and the rest is parameters telling it what ti do.
Photo of M

M

  • 80 Points 75 badge 2x thumb
how do i make QB return to the record after initiating the MailTo fuction?
when i'm editing the record i click the button and i'm advised to save my record first. Outlook opens correctly, but my QB form goes to a blank page.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
Can you post your current formula?
Photo of M

M

  • 80 Points 75 badge 2x thumb
"MailTo:user1@domain.com"

&"?cc=user2@domain.com; user3@domain.com; user4@domain.com"


&"&subject=Subject - "&[field name] &" - Site #: "&URLEncode([Site #])&" - Site Name: "&URLEncode([Site Name])

&"&body=user1,"&"%0A%0A"&
"Please send package for this site to:"&"%0A%0A"
&[Address]
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
not tested, but try this.

var text URLONE = "MailTo:user1@domain.com"
&"?cc=user2@domain.com; user3@domain.com; user4@domain.com"
&"&subject=Subject - "&[field name] &" - Site #: "&URLEncode([Site #])&" - Site Name: "&URLEncode([Site Name])
&"&body=user1,"&"%0A%0A"&
"Please send package for this site to:"&"%0A%0A"
&[Address];

var text URLTWO =
urlroot() & "db/" & dbid() & "?a=dr&rid=" & totext([record id#]);

$URLONE & "&rdr=" & URLEncode($URLTWO)
Photo of Michael

Michael

  • 160 Points 100 badge 2x thumb
Is it possible to embed a table of child records when creating an email like this?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 69,954 Points 50k badge 2x thumb
No. I don’t think so.

This conversation is no longer open for comments or replies.