FoxPro Programming
Twilio SendGrid for email sending with the West-Wind tools
Gravatar is a globally recognized avatar based on your email address. Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  All
  Sep 10, 2022 @ 06:27pm

I was wondering if anyone is using the West Wind tools to send email via Twilio's SendGrid API. I use Twilio for sending texts with the HTTPGet method in wwHTTP. Works great. Sending mail is a bit more complicated. Suggestions or examples would be appreciated.

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  Russell Campbell
  Sep 19, 2022 @ 07:38am

I'll take that as a "no." 😃

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Rick Strahl
  Russell Campbell
  Sep 20, 2022 @ 08:51pm

Doesn't mean it doesn't work though - just that nobody's done it and is willing to share. The APIs should be easy to access with wwHttp or possibly wwJsonServiceClient.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  Rick Strahl
  Sep 22, 2022 @ 07:00am

Well, sorting through the details is troublesome given the docs from Twilio. I don’t do this type of thing a lot, so it’s not second nature. Another person, can’t think of their name right now, has tools for this for VFP, so I may look into that. Some you have to pay for, some not. Not sure where the tools for SendGrid fall.

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  Rick Strahl
  Sep 24, 2022 @ 07:40pm

I'm trying to convert the examples he gives (see the previous link) and use your tools, but I'm unclear how to accomplish it. I created the appropriate object and used the JSON serializer to get the JSON created, but then posting it is a different challenge.

oEmail = createobject("Empty")
addproperty(oEmail, "personalizations", createobject("Empty"))
addproperty(oEmail.personalizations, "to", createobject("Empty"))
addproperty(oEmail.personalizations.to, "email", "someone@somewhere.com")
addproperty(oEmail.personalizations.to, "name", "Russell Campbell")
addproperty(oEmail, "from", createobject("Empty"))
addproperty(oEmail.from, "email", "someone@somewhere.com")
addproperty(oEmail, "subject", "Hello, world")
addproperty(oEmail, "content", createobject("Empty"))
addproperty(oEmail.content, "type", "text/plain")
addproperty(oEmail.content, "value", "Heya!")
do classes\wwJsonSerializer.prg
loSer = CREATEOBJECT("wwJsonSerializer")
lcJson =  loSer.Serialize(oEmail)

So that works out ok, but then posting it is not so obvious (to me, at least). Any thoughts (or sample code) here would be appreciated.

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  Russell Campbell
  Sep 27, 2022 @ 06:07am

Still was not sure what to use to get the API working, but I did discover that I had overlooked the step to set up my DNS entries. Had to create three CNAME records. Then was able to test using Telnet and that confirmed they could send email on my behalf. And then I noticed something else I'd overlooked which was I could send the email via a standards SMTP interface and that's working. My volume will be low, so that should suffice, but I would eventually like to get this working via the API.

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Phil Sherwood
  Russell Campbell
  Sep 27, 2022 @ 07:50am

We had to use the Chilkat tools to send and schedule emails with SendGrid. I'd be happy to share our code if you're interested.

Phil

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Rick Strahl
  Russell Campbell
  Sep 27, 2022 @ 02:22pm

Make sure you have the right case for each of those JSON keys as JSON is case sensitive.

You may need to use wwJsonSerializer::PropertyNameOverrides to force the property names to their proper case.

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  Phil Sherwood
  Sep 28, 2022 @ 07:32am

Thanks, Phil. I was trying to avoid buying another toolkit if Rick's would do it. And there are a number of VFP examples on the Chilkat site, so I was assuming that if I did buy it they would suffice to get me rolling. But I appreciate the offer.

Gravatar is a globally recognized avatar based on your email address. re: Twilio SendGrid for email sending with the West-Wind tools
  Russell Campbell
  Rick Strahl
  Sep 28, 2022 @ 07:35am

Rick, I did wonder if I should be using the JSONService tools and not just wwHTTP. But it's unclear to me as to what SendGrid is really expecting, so I'm unclear what and how to use your tools to supply it. But, as I mentioned, I got it working via a standard SMTP interface, so that will work for now.

© 1996-2022