Trying to use the smtp to addheader, but apparently the C# example works, but the code in wwsmtp.prg does not produce the same result.
lcx_smtpapi = '{"unique_args" : {"book_order" : "12345","chunky1" : "bacon1","dead" : "beef"},"sub" : {"%tag%" : ["\u79c1\u306f\u30e9\u30fc\u30e1\u30f3\u304c\u5927\u597d\u304d"]}}'
losmtp.addheader("X-SMTPAPI",lcx_smtpapi)
Not producing similar result as
public void AddUniqueArgs(IDictionary<string, string> identifiers)
{
foreach (string key in identifiers.Keys)
{
var keys = new List<string> {"unique_args", key};
string value = identifiers[key];
_settings.AddSetting(keys, value);
}
}private static string XsmtpapiHeaderAsJson()
{
var header = new Header();var uniqueArgs = new Dictionary<string, string>
{
{
"book_order",
"12345"
},
{
"chunky1",
"bacon1"
},
{
// UTF8 encoding test
Encoding.UTF8.GetString(Encoding.Default.GetBytes("dead")),
Encoding.UTF8.GetString(Encoding.Default.GetBytes("beef"))
}
};
header.AddUniqueArgs(uniqueArgs);
How do you format it properly? Any advice is much appreciated.
Thanks,
Joy
Joy
I have no idea.
You need to find out what hte actual header string looks like. Looking at the data I'm not sure you have the JSON properly formatted.
Either way - this isn't really a problem with wwSmtp but with the formatting of the actual value your are attaching to the header.
+++ Rick ---
Hi Rick,
Trying to use the smtp to addheader, but apparently the C# example works, but the code in wwsmtp.prg does not produce the same result.
lcx_smtpapi = '{"unique_args" : {"book_order" : "12345","chunky1" : "bacon1","dead" : "beef"},"sub" : {"%tag%" : ["\u79c1\u306f\u30e9\u30fc\u30e1\u30f3\u304c\u5927\u597d\u304d"]}}'
losmtp.addheader("X-SMTPAPI",lcx_smtpapi)
Not producing similar result as
public void AddUniqueArgs(IDictionary<string, string> identifiers)
{
foreach (string key in identifiers.Keys)
{
var keys = new List<string> {"unique_args", key};
string value = identifiers[key];
_settings.AddSetting(keys, value);
}
}private static string XsmtpapiHeaderAsJson()
{
var header = new Header();var uniqueArgs = new Dictionary<string, string>
{
{
"book_order",
"12345"
},
{
"chunky1",
"bacon1"
},
{
// UTF8 encoding test
Encoding.UTF8.GetString(Encoding.Default.GetBytes("dead")),
Encoding.UTF8.GetString(Encoding.Default.GetBytes("beef"))
}
};
header.AddUniqueArgs(uniqueArgs);
How do you format it properly? Any advice is much appreciated.
Thanks,
Joy
West Wind Technologies
Making waves on the Web
from Maui
Actually, it wasn't the format. Somehow the smtp header was not added.
Here is my code:
lcx_smtpapi = '{"unique_args" : {"foox" : "barx","chunky" : "bacon","dead" : "beef"}}'
losmtp.ccclist = "joyt@norco.com"losmtp.crecipient = "joytan@shaw.ca"
losmtp.csubject = "test from joy - one"
losmtp.cmessage = "Salvation is found in no one else, for there is no other name under heaven given to men by which we must be saved."
losmtp.addheader("X-SMTPAPI",lcx_smtpapi)
Here is my packet trace:
220 SG ESMTP service ready at ismtpd0005p1iad1.sendgrid.net
EHLO lptdev1
250-smtp.sendgrid.net
250-8BITMIME
250-PIPELINING
250-SIZE 31457280
250-STARTTLS
250-AUTH PLAIN LOGIN
250 AUTH=PLAIN LOGIN
AUTH login aXRAbm9yY28uY29t
334 UGFzc3dvcmQ6
M0JqNndGWE9HNEF2WDVWMWVmNG8=
235 Authentication successful
MAIL FROM:<noreply@ltpdealer.com>
250 Sender address accepted
RCPT TO:<joytan@shaw.ca>
250 Recipient address accepted
RCPT TO:<joyt@norco.com>
250 Recipient address accepted
DATA
354 Continue
x-mailer: West Wind SMTP 5.0
MIME-Version: 1.0
From: "Joy Tan" <noreply@ltpdealer.com>
To: joytan@shaw.ca
Cc: joyt@norco.com
Date: 8 Oct 2015 11:29:31 -0700
Subject: test from joy - one
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printableSalvation is found in no one else, for there is no other name under heaven=
given to men by which we must be saved..
250 Ok: queued as 9AQ13LLyRXGFdp6G4mhPVg
As you can see, there were not smtp headers added.
Thanks,
Joy
Joy