I am trying to get a value and use it in sendgrid email template. The JSON looks like this.
"productskumapping" : {
"created/updated" : 2,
"failed" : 0
}
{{productskumapping.created/updated}} does not give any value in the email template. the macro is not replaced. But the macro must replace with 2. How to make this work? the slash character("/") is causing the issue. Please sugggest any solution for this.
Twilio SendGrid developer evangelist here.
SendGrid uses handlebars style expressions to interpolate data. I just learned that slashes were a deprecated way that handlebars the library used to navigate objects. I don't know if SendGrid uses that exact handlebars library internally, but I thought it was important.
I believe the way to get around a slash in a key, like you have, is to surround the key with square brackets instead. This is known as literal segments and would look like this for you:
{{productskumapping.[created/updated]}}
Related
I'm trying to make an auto response for a website, let me take an exemple
Website : http://mywebsite.com/1.0/?appID=blah_blah&appVersion=RandomNumber&getAppicationSettings=blah_blah
I'd like that Fiddler match the autoresponse after, for exemple, "appVersion=" I've tried to put "REGEX:http://mywebsite.com/1.0/?appID=blah_blah&appVersion=.*" but it doesn't work.
I don't know if you know what I mean, I have trouble to explain it. :(
Thanks for the reply.
The simplest thing would be to just change the rule to
http://mywebsite.com/1.0/?appID=blah_blah&appVersion=
If you need to use a regular expression, the expression needs to be valid, with escaping of characters that have a meaning in regular expressions. E.g. more like:
REGEX:mywebsite\.com\/1\.0\/\?appID=blah_blah&appVersion=[\d]+&getAppicationSettings=blah_blah
We have a list of address, And trying to get coordinates of them using server side script.
Due to limitation of google map api(2500 query per 24 hour), We move to bing map REST api.
But when we are calling API its not giving the coordinates, While google map api returning the correct coordinates.
Please tell me what i am doing wrong?
Here is the sample call
http://dev.virtualearth.net/REST/v1/Locations?query=A+Beka+Acadamdy,2303+Maravilla,Lompoc,CA,93436,&incl=queryParse&key=MY_API_KEY
if I replace everything with %20 in address then still its not returning data
http://dev.virtualearth.net/REST/v1/Locations?query=A%20Beka%20Acadamdy%202303%20Maravilla%20Lompoc%20CA%2093436&incl=queryParse&key=MY_API_KEY
Another URL is
http://dev.virtualearth.net/REST/v1/Locations?query=103+Black+Men+of+the+Bay+Area+Community,3403+Malcolm+Avenue,Oakland,CA,94607-1407,&incl=queryParse&key=MY_API_KEY
We also tried with this
https://msdn.microsoft.com/en-us/library/ff817004.aspx#sectionToggle6
But sometimes we don't know the country, That's why its not working correctly.
A couple of things to change. First, drop the name of the location, you only need the street address.
So geocoding "2303 Maravilla, Lompoc, CA, 93436" will work.
Secondly, it looks like you are escaping the query value rather than encoding it. Escaping isn't as good as encoding and will result in some queries failing all together. For example if a query had "first & Main" in it, escaping it would not escape the ampersand which would make everything after it a new URL parameter which would likely either cause an error or mean your query is just for "first". By encoding it the ampersand would be changed to %26. This is documented in the best practices here: https://msdn.microsoft.com/en-us/library/dn894107.aspx
By encoding your query parameter your address will look like this:
"2303%20Maravilla,%20Lompoc,%20CA,%2093436"
How can I get the email address out of a string like:
def emailAddress="john#doe.com <\john#doe.com\\>"
so that I can use it in a call to Contactperson.findByEmailAddress(variable)
JavaMail provides a class for representing email addresses that can parse strings in the format you have. Take a look at javax.mail.internet.InternetAddress.
Grails has a mail plugin that will automatically make JavaMail available.
A simple solution is
Contactperson.findByEmailAddress(emailAddress.split('<')[0])
But you need to do some validation work first to avoid format errors.
I'm assuming the email you need to compare is inside the brackets:
Contactperson.findByEmailAddressIlike('%<${variable}>%')
You'll probably need to escape the special characters depending on your database.
What I'm trying to do is format the email address like so Foo Bar <foo#bar.com> so email clients (including web based like gmail) will show the sender as "Foo Bar" and not just "foo" since that is the prefix on the email.
Is this possible in Magento 1.5? If I try to put the formatting in the field itself I get an error message.
That's what the Sender Name field does. This is what my setup looks like and what it looks like in Thunderbird (my webmail client formats it similarly, too):
You may look at code/core/Mage/Core/Model/Email.php for the actual mail implementation. You may notice it uses Zend_Mail. Now, here is the catch:
For security reasons, Zend_Mail filters all header fields to prevent header
injection with newline (\n) characters. Double quotation is changed to single
quotation and angle brackets to square brackets in the name of sender and recipients.
If the marks are in email address, the marks will be removed.
What you can do though is to make a module to rewrite the current class Mage_Core_Model_Email and overwrite the send() function. I covered rewriting classes before in this question's answer. Then, in this new rewritten class, you could PHPmailer, invoke shell mail commands, or whatever PHP library you would happen to know that would allow this behaviour.
Best of luck.
I'm not sure if it can work. In magento inside is a Zend_Validate which does validation of such email addresses. And I dont think so that email like 'Foo Bar ' is valid. But I think the display in customer's email client depend on client, no?
I am looking for the syntax to add node fields to the body of an email. Examples I looked at the documentation, and the format is [content_type:content_type_title].
However, my email arrives with just the string [content_type:content_type_title].
Even better would be a PHP snippet that loads the node and dumps filed title and filed value into the body of the message.
Rules supports the Token module, which should allow you to do something like that.
Use node_load($nid) or db_query to get the node you want, use that in the email function you are creating.