Help get this topic noticed by sharing it on Twitter Twitter, Facebook Facebook, or email.
emojunior

Need Substitution tag HTML example

Ref: http://docs.sendgrid.com/documentatio...

The example HTML doesn't contain <% body %> tag. I tried, nothing gets replaced.
Pls show an example of where to implement the <% body %> with HTML content.

This is what I have:


<% body %>
Hello %name%

Some test for substitution Result: %result%



(This same content is in the text parameter for the webapi.)

However, this is what I see when I open the email:
<html> <head></head> <%body%> <p>Hello
Roy</p> <p>Some test for substitution Result:
Success!!</p> </html>
Hello %name%
Some test for substitution Result: %result%
1 person has
this question
+1
Reply

  • Jacob (Support Engineer) January 18, 2012 14:13
    You would only use %body% if you have it defined in the SMTP-API. I can't see why you'd do that, since you are wanting it to actually say body. Maybe you're getting this confused with our Email Template App, which uses that tag but for an entirely different purpose?

    The intended functionality, to use your example would have this in the SMTPAPI header:
    {"to":["emo@example.com", "jacob@sendgrid.com"], "sub":{"%name%":["Emo", "Jacob"],"%result%":["Success","Failure"]}}

    Then, in the body, for the the message to you, we would replace every appearance of %name% with Emo, and every appearance of %result% with Success. On the second send, it would have Jacob & Failure instead.

    If this isn't working for you, please let me know, and we'll convert this to a ticket to better take care of you.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • emojunior
    Hi Jacob,

    I tried putting the contents (my template) into the "html" parameter of the webapi. It works fine now.

    Yes I think I'm confused between the Email template and the Email body part. Aren't they supposed to be the same?

    Which scenario would there be a different body and template? Or, what is the purpose of loading the template using $this->_ci->smtpapiheaderl->addFilterSetting('template', 'text/html', $this->get_template_content($template)); Where get_template_content retrieves the contents of the template.

    I'm using the webapi and filling in the x-smtpapi headers where needed.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • Jacob (Support Engineer) January 19, 2012 14:54
    The Email Template app is basically a "wrapper". The proper use is that when building the template, you, include the < % body % > tag like so:

    header HTML, logo, inline css, etc
    < % body % >
    footer HTML.

    spaces so the tag shows.

    Then, you can just send us simple messages, and we insert it where the tags are. Whenever you get a "somebody sent you a message" email, that's simple in the middle, and only "pretty" on the outside, that's the type of thing Email Template does.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • emojunior
    So the text will be replaced with the contents of the email sent to sendgrid? Do you mean the body received through the parse api?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • Jacob (Support Engineer) January 25, 2012 16:19
    If you're using the email template app, everything in your message body will be put in where the tag is.

    Parse API is for inbound email only, and is completely different.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • emojunior
    Ok, I'm still confused about sending the email to you and parsing inbound email part.

    What do you mean by send email to you? Which email address is that?

    As for parsing of email, lets say my domain is mydomain.com, will the mail be directed to the URL I set in Parse API settings page, noting that I'd set the MX Record to mx.sendgrid.net.
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited

  • Jacob (Support Engineer) January 27, 2012 22:44
    Our primary product is the SMTP relay, in which you have your system connect to us at smtp.sendgrid.net, you relay a message to us, and we deliver it to the final recipient on your behalf.

    We also provide an Inbound Parsing service, wherein we take all the mail send to a domain (or subdomain) that you've defined and added the MX record for. We then POST that to a URL of your choosing. So you're correct on that part.
    However, with Parse API, there's no use of "substitution tags".

    I think we've broken down on terminology. Could you restate your question, or email us so that we can help you better?
  • (some HTML allowed)
    How does this make you feel?
    Add Image
    I'm

    e.g. sad, anxious, confused, frustrated indifferent, undecided, unconcerned kidding, amused, unsure, silly happy, confident, thankful, excited