Hi, 

I`m building an web app that registers a client, and after the registration I want to send an Email to this client with a QrCode with his Data (Name,Company,Date ...).


I've installed the 'SimpleQRCodeGenerator' and made the logic to generate him. The action returns me a 'Binary Data', but I don't know how to put the QRCode in the Email.

i tried to make an expression, but it only takes a 'Text' data type. 


Can anyone help me ?

Hi Joao,


the binary output you are getting is an image, so the question is how you want to put this image in the mail.  

I'm  no expert with mail content, but an option would be to serve up the image from you're outsystems server and including the image in your mail with the correct url.  

See this post for the way to build that server.

Based on the idea of Andres : 

  • build a screen that takes in the id of the client registration, as an input parameter
  • make sure the screen is available to anonymous users
  • in the Preparation
    • fetch whatever data you need
    • do the necessary checks to see if it is safe to return the QR (i.e. it's a valid request and not an attack)
    • call the GenerateQRCode Action
    • End on a Download node
    • you could even add logic in the screen to log the fact that the server was called with that id, which means (maybe) that the client has seen the mail (or maybe not, dependent on mail software, etc.)


Now in your email, add an image with as URL this page of yours, passing in the correct id, that should get you the correct QR image in the mail.

So what to use for id, should probably be encoded into some weird long string, but don't know much about security, so can't help you there.

This is not a working solution, but might get you pointed in the right direction.

Hi João,

I believe Dorine's solution works pretty well, but in case you want to inline the images you can consider what's discussed here and here.

Hope this helps!

Dorine Boudry wrote:

Hi Joao,


the binary output you are getting is an image, so the question is how you want to put this image in the mail.  

I'm  no expert with mail content, but an option would be to serve up the image from you're outsystems server and including the image in your mail with the correct url.  

See this post for the way to build that server.

Based on the idea of Andres : 

  • build a screen that takes in the id of the client registration, as an input parameter
  • make sure the screen is available to anonymous users
  • in the Preparation
    • fetch whatever data you need
    • do the necessary checks to see if it is safe to return the QR (i.e. it's a valid request and not an attack)
    • call the GenerateQRCode Action
    • End on a Download node
    • you could even add logic in the screen to log the fact that the server was called with that id, which means (maybe) that the client has seen the mail (or maybe not, dependent on mail software, etc.)


Now in your email, add an image with as URL this page of yours, passing in the correct id, that should get you the correct QR image in the mail.

So what to use for id, should probably be encoded into some weird long string, but don't know much about security, so can't help you there.

This is not a working solution, but might get you pointed in the right direction.


Thank you Dorine, It really helped.


I've made the new screen that generates the qrcode file. But, just the email part of creating the image with the URL, I tried, but I'm can't see where I'm doing it wrong.

I'm getting this Error massage:

 and my image in the email is with this URL:


I think is the fact that my screen that generates the QRCode, recives an input with the Id of the client.

So, in this URL, maybe I should pass the input path ..


Can you help me one more time ? 

Solution

Hi Joao,


I'm still new to Outsystems, so I don't really know what the best practices are for things like referring to paths or composing and sending mails, etc., I don't really know how to get some sort of relative path to your server in the URL of the image in your mail.  I tried an example with GetOwnerUrlPath() and got same kind of error message like you did.


(by the way, what you are trying is far off, you get the word 'False' in your test because instead of setting a path, you compare the result of GetOwnerUrlPath() to a literal string, and that returns False)


So Caveat Emptor, following is purely as a step in the right direction, not production quality software :


What works for me as a test, is to just use the full literal URL.  


A good test would be to keep trying until you can enter the url in the browser, and it starts the download of your QR image.  That's the URL you can use as 'external' for your image in your mail. 

in my example that would be 

"dorineboudry.outsystemscloud.com/QRTest/ViewQRDocument.aspx?id=5"


so as image url, try something like

"joao-tiburcio.outsystemscloud.com/Registrationweb/<screenname>.aspx?<inputname>="+ variable

fill in the correct <screenname> and <var>, and use the right variable (probably an id or something ?)

this is how mine looks :


I can see mails coming out in Service Studio, but I haven't got any SMTP configuration set up, so can't see the content.

hope this helps you a bit further,

Dorine




Solution

João,

If you are following Dorine's approach, then just like she mentioned, your first issue seems to be you have a typo and have an = sign instead of a + sign in your expression.

If you need to provide directly your QRcode URL, instead of Dorine's suggestion:

"https://environment-name/RegistrationWeb/screen-name.aspx?input-name=" + value

I'd go with a simplified version that ends up with the same outcome and is a bit more generic, as it is a relative:

"screen-name.aspx?input-name=" + value

where:

  • environment-name is your environment's hostname (in your case would be joao-tiburcio.outsystemscloud.com);
  • screen-name is the name of your Web Screen that generates the QRcode;
  • input-name is the name of the input parameter that your screen receives and will be used to retrieve the correct registration information;
  • value is the actual identifier/code that uniquely identifies a registration.

if your URL doesn't start with the protocol part (https://), it's automatically assumed to be on your server. If the url doesn't start with a slash (/), it's going to be relative to the current screen's/application location (even on Email Screens).

Hope this clarifies things a bit more.

Dorine Boudry wrote:

Hi Joao,


I'm still new to Outsystems, so I don't really know what the best practices are for things like referring to paths or composing and sending mails, etc., I don't really know how to get some sort of relative path to your server in the URL of the image in your mail.  I tried an example with GetOwnerUrlPath() and got same kind of error message like you did.


(by the way, what you are trying is far off, you get the word 'False' in your test because instead of setting a path, you compare the result of GetOwnerUrlPath() to a literal string, and that returns False)


So Caveat Emptor, following is purely as a step in the right direction, not production quality software :


What works for me as a test, is to just use the full literal URL.  


A good test would be to keep trying until you can enter the url in the browser, and it starts the download of your QR image.  That's the URL you can use as 'external' for your image in your mail. 

in my example that would be 

"dorineboudry.outsystemscloud.com/QRTest/ViewQRDocument.aspx?id=5"


so as image url, try something like

"joao-tiburcio.outsystemscloud.com/Registrationweb/<screenname>.aspx?<inputname>="+ variable

fill in the correct <screenname> and <var>, and use the right variable (probably an id or something ?)

this is how mine looks :


I can see mails coming out in Service Studio, but I haven't got any SMTP configuration set up, so can't see the content.

hope this helps you a bit further,

Dorine




It worked !!!

Actually, in gmail, my qrcode does not appear (I still trying to figure it out), but in outlook it works perfectly!!


Thank you very much Dorine !!  


Jorge Martins wrote:

João,

If you are following Dorine's approach, then just like she mentioned, your first issue seems to be you have a typo and have an = sign instead of a + sign in your expression.

If you need to provide directly your QRcode URL, instead of Dorine's suggestion:

"https://environment-name/RegistrationWeb/screen-name.aspx?input-name=" + value

I'd go with a simplified version that ends up with the same outcome and is a bit more generic, as it is a relative:

"screen-name.aspx?input-name=" + value

where:

  • environment-name is your environment's hostname (in your case would be joao-tiburcio.outsystemscloud.com);
  • screen-name is the name of your Web Screen that generates the QRcode;
  • input-name is the name of the input parameter that your screen receives and will be used to retrieve the correct registration information;
  • value is the actual identifier/code that uniquely identifies a registration.

if your URL doesn't start with the protocol part (https://), it's automatically assumed to be on your server. If the url doesn't start with a slash (/), it's going to be relative to the current screen's/application location (even on Email Screens).

Hope this clarifies things a bit more.


Thank you too Jorge, your explanation also helped me! 

Joao Tiburcio wrote:

It worked !!!

Actually, in gmail, my qrcode does not appear (I still trying to figure it out), but in outlook it works perfectly!!


Thank you very much Dorine !!  


Yes, I think there is a lot of debate about the way that you should incorporate images in mails (url / inline / cid) , different mail programs react in different ways, sometimes blocking the rendering or putting the mail in spam because of it.  This isn't really an outsystems problem, a lot can be found in places like StackOverflow. 

As others have mentioned, you could try to send it as an inline Base64 string.  All the pros and cons of how to send images in mails is not something I can help with, but good luck with it.

Dorine


Hi João,

At least one of the topics I mentioned earlier point to stack overflow discussions on how to support inline images in different email clients (whether they are web applications or not), as some clients will block remote images due to privacy concerns. Mostly clients will support inline images, but how they present the email might depend on the size of the inline image (email clients tend to have strict limits on the size of emails they fully display upfront).

I believe Dorine's solution works pretty well, but in case you want to inline the images you can consider what's discussed here and here.