Add image from WRD schema settings to mail

11 views
Skip to first unread message

Wouter Hendriks

unread,
Jun 6, 2021, 2:42:30 PM6/6/21
to General WebHare developers discussion
Hi,

Tried everything but can't seem to find how to add an image blob to an email generated by PrepareMailWitty.

Image comes from WRD schema settings and because of this I don't have a wrapped version available, eg only the blob. Tried:

- GetDataURL for <img src> (seems to work in RunEmailTestDialog but not in the sent email itself)
- WittyMailComposer::AddEmbeddedObject and use its result in <img src>; the cid-string shows up in email source but the image doesn't appear to be added to the mail

There doesn't seem to be something in webhare_testsuite for this either, unless I'm not reading the tests correctly.

After some debugging, it looks like the last param in

```
RECORD toppart := CreateMIMEMailingTopPart(textversion, prep.htmlversion, this->embeddedassets);
```

is an empty record array. This seems to be caused by:

```
  PUBLIC RECORD FUNCTION __PrepareContent()
  {
    this->embeddedassets := RECORD[];
```

If I comment this line, all seems to go well, both in RunEmailTestDialog as well as the sent email. But I'd guess this line is there for a reason. Is it?



Arnold Hendriks

unread,
Jun 6, 2021, 4:53:50 PM6/6/21
to General WebHare developers discussion, Wouter Hendriks
I would have expected GetCachedImageLInk to work here - that's what's also being tested by TestMailWitty_EmbedSafety

embeddedassets is cleared at the start of PrepareContent so that using eg. QueueMail twice on the same mail doesn't cause the assets to be duplicated. AddEmbeddedObject is used internally during mail rendering, so if invoked anywhere during the running of the mail's witty it probably does work (and that's probably what is got used for so far in practice). It probably shouldn't be clearing embeddedassets at the start of PrepareContent but restore it to its initial value somehow so that multiple QueueMail calls don't embed images generated during rendering multiple times.

I don't see why a dataurl wouldn't work though. Something would have to be explicitly breaking that then.

Wouter Hendriks

unread,
Jun 7, 2021, 5:47:18 AM6/7/21
to General WebHare developers discussion, Arnold Hendriks
Using this code:

mail->mergerecord :=  ... logo := GetDataUrl(data,mimetype) ...

Output is:

src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASA.....

The image shows up correctly in the test mail dialog, but is missing in Gmail. 

It does show up correctly in iOS and OSX mail apps though... so it seems it's just Gmail that doesn't understand it.

GetCachedImageLInk(WrapBlob(...)) results in:

"GetCachedImageLink requires a WHFS Setting, WRD Setting or WHFSObject GetWrapped() record."

As the image comes from wrdschema->GetSchemaSetting, I have no idea how to get the wrapped record.





Arnold Hendriks

unread,
Jun 8, 2021, 3:14:57 AM6/8/21
to General WebHare developers discussion
On Mon, 7 Jun 2021 at 11:47, Wouter Hendriks <wou...@webwerf.nl> wrote:
Using this code:

mail->mergerecord :=  ... logo := GetDataUrl(data,mimetype) ...

Output is:

src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASA.....

The image shows up correctly in the test mail dialog, but is missing in Gmail. 
 
It does show up correctly in iOS and OSX mail apps though... so it seems it's just Gmail that doesn't understand it.

I guess gmail broke this when they started rehosting images embedded into mail. Guess noone at google knows about data: urls ? :) 

RewriteRTDEmbeddedLink in mailer.whlib probably has to be extended to support data URLs and rewrite them to embedded assets


Wouter Hendriks

unread,
Jun 8, 2021, 5:48:37 AM6/8/21
to General WebHare developers discussion, Arnold Hendriks
Is there a way to convert a "random" blob into a (cached) (absolute) file link, in this case a blob provided by wrdschema->GetSchemaSetting? (other than through tollium_todd.res / SendWebFile?)

Arnold Hendriks

unread,
Jun 8, 2021, 5:51:38 AM6/8/21
to General WebHare developers discussion
On Tue, 8 Jun 2021 at 11:48, Wouter Hendriks <wou...@webwerf.nl> wrote:
Is there a way to convert a "random" blob into a (cached) (absolute) file link, in this case a blob provided by wrdschema->GetSchemaSetting? (other than through tollium_todd.res / SendWebFile?)

Store it in one of the three locations supported by the image cache.

Wouter Hendriks

unread,
Jun 8, 2021, 6:46:46 AM6/8/21
to General WebHare developers discussion, General WebHare developers discussion
Okay, opting for a settings WRD object then.

Thnx!
Reply all
Reply to author
Forward
0 new messages