comp.lang.ada
 help / color / mirror / Atom feed
* Sending HTML e-mail
@ 2016-01-24  4:25 John Smith
  2016-01-24 16:12 ` Dennis Lee Bieber
  0 siblings, 1 reply; 10+ messages in thread
From: John Smith @ 2016-01-24  4:25 UTC (permalink / raw)


Hi,

One thing that I'd like to do in Ada is to send an HTML file and have that 
display as the actual e-mail itself (for example, in Outlook.)  Basically, not as 
an attachment to the e-mail, but inside the message of it.

Here are the steps that I took and the results that I got:
- The first thing I did was have a look at this example:
  http://rosettacode.org/wiki/Send_email#Ada

Where it says message, I entered HTML and my e-mail never got to my Outlook 
Inbox.  The plain text worked though.

- Then, I tried turning HTML code into (which is in a plain HTML file) an 
attachment and then sending that out.  Well, this e-mail did get to where it was 
supposed to get to, but it had an attachment that was an HTML file.  I tried 
something similar in a different programming language and it worked as I've 
previously described.

So, I have this question.  How can I create a plain table in HTML and then send it out?


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-24  4:25 Sending HTML e-mail John Smith
@ 2016-01-24 16:12 ` Dennis Lee Bieber
  2016-01-26  1:09   ` Randy Brukardt
  0 siblings, 1 reply; 10+ messages in thread
From: Dennis Lee Bieber @ 2016-01-24 16:12 UTC (permalink / raw)


On Sat, 23 Jan 2016 20:25:04 -0800 (PST), John Smith
<yoursurrogategod@gmail.com> declaimed the following:

>Hi,
>
>One thing that I'd like to do in Ada is to send an HTML file and have that 
>display as the actual e-mail itself (for example, in Outlook.)  Basically, not as 
>an attachment to the e-mail, but inside the message of it.
>
>Here are the steps that I took and the results that I got:
>- The first thing I did was have a look at this example:
>  http://rosettacode.org/wiki/Send_email#Ada
>
>Where it says message, I entered HTML and my e-mail never got to my Outlook 
>Inbox.  The plain text worked though.
>
>- Then, I tried turning HTML code into (which is in a plain HTML file) an 
>attachment and then sending that out.  Well, this e-mail did get to where it was 
>supposed to get to, but it had an attachment that was an HTML file.  I tried 
>something similar in a different programming language and it worked as I've 
>previously described.
>
>So, I have this question.  How can I create a plain table in HTML and then send it out?

	1)	You will likely have to have the entire body of the message as HTML
-- not just something contained within it. (Unless you actually go to the
extent of using multipart/mixed or some such, in which you embed multiple
forms of the message: text/plain, text/html, etc. and let the reading
client pick the one it can best handle)

	2)	You will have to have a means of controlling the SMTP headers to be
able to define that the message body follows MIME format and contains HTML


	Suggest studying 
https://tools.ietf.org/html/rfc2045 
https://tools.ietf.org/html/rfc2046
and 
https://www.ietf.org/rfc/rfc2854.txt
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-24 16:12 ` Dennis Lee Bieber
@ 2016-01-26  1:09   ` Randy Brukardt
  2016-01-26 23:09     ` John Smith
  0 siblings, 1 reply; 10+ messages in thread
From: Randy Brukardt @ 2016-01-26  1:09 UTC (permalink / raw)


"Dennis Lee Bieber" <wlfraed@ix.netcom.com> wrote in message 
news:a7t9abpg2p6ghs65f6agsase7cltp9ad8e@4ax.com...
> On Sat, 23 Jan 2016 20:25:04 -0800 (PST), John Smith
> <yoursurrogategod@gmail.com> declaimed the following:
...
>>So, I have this question.  How can I create a plain table in HTML and then 
>>send it out?
>
> 1) You will likely have to have the entire body of the message as HTML
> -- not just something contained within it. (Unless you actually go to the
> extent of using multipart/mixed or some such, in which you embed multiple
> forms of the message: text/plain, text/html, etc. and let the reading
> client pick the one it can best handle)

And you really ought to do that; not all mail clients can do anything useful 
with HTML.

                           Randy.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-26  1:09   ` Randy Brukardt
@ 2016-01-26 23:09     ` John Smith
  2016-01-26 23:18       ` John Smith
                         ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: John Smith @ 2016-01-26 23:09 UTC (permalink / raw)


On Monday, January 25, 2016 at 8:09:57 PM UTC-5, Randy Brukardt wrote:
> "Dennis Lee Bieber" <wlfr...@ix.netcom.com> wrote in message 
> news:a7t9abpg2p6ghs65f6agsase7cltp9ad8e@4ax.com...
> > On Sat, 23 Jan 2016 20:25:04 -0800 (PST), John Smith
> > <yoursu....@gmail.com> declaimed the following:
> ...
> >>So, I have this question.  How can I create a plain table in HTML and then 
> >>send it out?
> >
> > 1) You will likely have to have the entire body of the message as HTML
> > -- not just something contained within it. (Unless you actually go to the
> > extent of using multipart/mixed or some such, in which you embed multiple
> > forms of the message: text/plain, text/html, etc. and let the reading
> > client pick the one it can best handle)
> 
> And you really ought to do that; not all mail clients can do anything useful 
> with HTML.
> 
>                            Randy.

Hi, thanks for your response.

I don't mind building the actual String in HTML from scratch, that's easy.  The question that I have is, once I have that built exactly how I want it, how can I send it and have it be delivered as an HTML e-mail?

I thought about using AWS.Response.Build for this, it returns a Data object... but I'm not sure how to e-mail it...

I'm confident that I'm missing something that is relatively self-evident, but not quite making the connection necessary to make it work.

If someone could show me a very simple example (it doesn't even need to be compilable), that would be very helpful.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-26 23:09     ` John Smith
@ 2016-01-26 23:18       ` John Smith
  2016-01-26 23:18       ` John Smith
  2016-01-28  0:14       ` Randy Brukardt
  2 siblings, 0 replies; 10+ messages in thread
From: John Smith @ 2016-01-26 23:18 UTC (permalink / raw)


I'd like to e-mail something like this as a first go:

<html><head><title>foo</title></head><body><p>bar</p></body></html>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-26 23:09     ` John Smith
  2016-01-26 23:18       ` John Smith
@ 2016-01-26 23:18       ` John Smith
  2016-01-27  2:29         ` Dennis Lee Bieber
  2016-01-28  0:14       ` Randy Brukardt
  2 siblings, 1 reply; 10+ messages in thread
From: John Smith @ 2016-01-26 23:18 UTC (permalink / raw)


I'd like to e-mail something like this as a first go:

<html><head><title>foo</title></head><body><p>bar</p></body></html>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-26 23:18       ` John Smith
@ 2016-01-27  2:29         ` Dennis Lee Bieber
  0 siblings, 0 replies; 10+ messages in thread
From: Dennis Lee Bieber @ 2016-01-27  2:29 UTC (permalink / raw)


On Tue, 26 Jan 2016 15:18:47 -0800 (PST), John Smith
<yoursurrogategod@gmail.com> declaimed the following:

>I'd like to e-mail something like this as a first go:
>
><html><head><title>foo</title></head><body><p>bar</p></body></html>

	I've never used AWS so this is all coming from web searches...

https://docs.adacore.com/aws-docs/aws/apiref.html#aws-smtp-client
Bottom of the section has... 

> procedure Send
>     (Server      : Receiver;
>      From        : E_Mail_Data;
>      To          : Recipients;
>      Subject     : String;
>      Attachments : AWS.Attachments.List;
>      Status      : out SMTP.Status;
>      CC          : Recipients := No_Recipient;
>      BCC         : Recipients := No_Recipient);
>   --  As above but takes an attachment list which support complex attachments
>   --  like multiplart/alternative.

	Which should allow you to embed your HTML as one of the /alternative/
representations (I need to find the docs on the attachments.list...)

https://docs.adacore.com/aws-docs/aws/apiref.html#aws-attachments

>  function Value
>     (Data         : String;
>      Name         : String := "";
>      Encode       : Encoding := None;
>      Content_Id   : String := "";
>      Content_Type : String := MIME.Text_Plain) return Content;
>   --  A string as content

	So... I'd presume you'd pass your HTML string as Data, specify
MIME.Text_HTML...

>   type Alternatives is private;
>
>   procedure Add
>     (Parts : in out Alternatives;
>      Data  : Content);
>   --  Add an alternative content
>

	Then add it to the actual message with... (well, actually -- first add
it to an Alternatives structure...)

>   procedure Add
>     (Attachments : in out List;
>      Parts       : Alternatives);
>   --  Add an alternative group to the current attachment list

... then add it to the "attachments" list, and THEN use the above Send...



-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-26 23:09     ` John Smith
  2016-01-26 23:18       ` John Smith
  2016-01-26 23:18       ` John Smith
@ 2016-01-28  0:14       ` Randy Brukardt
  2016-01-28  3:11         ` John Smith
  2 siblings, 1 reply; 10+ messages in thread
From: Randy Brukardt @ 2016-01-28  0:14 UTC (permalink / raw)


"John Smith" <yoursurrogategod@gmail.com> wrote in message 
news:a2e513fe-a1ce-452e-903e-a497f9d83e0d@googlegroups.com...
> On Monday, January 25, 2016 at 8:09:57 PM UTC-5, Randy Brukardt wrote:
>> "Dennis Lee Bieber" <wlfr...@ix.netcom.com> wrote in message
>> news:a7t9abpg2p6ghs65f6agsase7cltp9ad8e@4ax.com...
>> > On Sat, 23 Jan 2016 20:25:04 -0800 (PST), John Smith
>> > <yoursu....@gmail.com> declaimed the following:
>> ...
>> >>So, I have this question.  How can I create a plain table in HTML and 
>> >>then
>> >>send it out?
>> >
>> > 1) You will likely have to have the entire body of the message as HTML
>> > -- not just something contained within it. (Unless you actually go to 
>> > the
>> > extent of using multipart/mixed or some such, in which you embed 
>> > multiple
>> > forms of the message: text/plain, text/html, etc. and let the reading
>> > client pick the one it can best handle)
>>
>> And you really ought to do that; not all mail clients can do anything 
>> useful
>> with HTML.
>>
>>                            Randy.
>
> Hi, thanks for your response.
>
> I don't mind building the actual String in HTML from scratch, that's easy. 
> The question that I have is,
>once I have that built exactly how I want it, how can I send it and have it 
>be delivered as an HTML e-mail?

It's not that easy to do. The easiest way is to use a library constructed 
for that purpose. I use one that originated with Tom Moran built on top of 
Claw Sockets or NC Sockets. (And I've more recently redesigned it to work 
better in my spam filter and it's related tools.)

But of course to use Claw.Sockets you have to have the paid version of Claw. 
The original version of NC Sockets only works on Windows; I once started a 
more generic version but never quite finished it (maybe this year).

And I note that the NC_SMTP that I have doesn't have the ability to set the 
content type (and even if it did, sending just an HTML message is evil --  
you have to send a text equivalent along with it. Indeed, many spam filters 
substantially increase the spam score for messages where the text and HTML 
have different contents -- it's important to get that right). I've never 
needed that; the primary use I've had for this library is to send bounce 
messages for undeliverable mail -- and that is always a plain text function 
that does not copy much of the original message (if you include the original 
message, spammers will bounce spam off of your mail server in order to use 
it to originate the spam).

One can trivially send a text message in NC_SMTP using the simple send 
function:

     NC_SMTP.Open (Session => My_Session,
                                   IP => Target_Ip);
     NC_SMTP.Send_Simple_Message (Session => My_Session,
                                                              Sender => 
"randy@rrsoftware.com",
                                                              Recipient => 
ada-comment@ada-auth.org,
                                                              Subject => 
"Ada is great",
                                                              The_Body => 
...);
     NC_SMTP.Close (Session => My_Session);

Here, the body is a linked list of Unbounded_Strings, each string 
representing a line (I won't show the construction of those - it should be 
obvious). And Target_IP can be figured out by using the Lookup_Host_Info 
function (this is the interface to DNS in Claw.Sockets and NC.Sockets).

There's probably some public library out there that does this stuff, but I 
don't know anything about it.

                                     Randy.







^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-28  0:14       ` Randy Brukardt
@ 2016-01-28  3:11         ` John Smith
  2016-01-28 21:42           ` Randy Brukardt
  0 siblings, 1 reply; 10+ messages in thread
From: John Smith @ 2016-01-28  3:11 UTC (permalink / raw)


> It's not that easy to do. The easiest way is to use a library constructed 
> for that purpose. I use one that originated with Tom Moran built on top of 
> Claw Sockets or NC Sockets. (And I've more recently redesigned it to work 
> better in my spam filter and it's related tools.)
> 
> But of course to use Claw.Sockets you have to have the paid version of Claw. 
> The original version of NC Sockets only works on Windows; I once started a 
> more generic version but never quite finished it (maybe this year).
> 
> And I note that the NC_SMTP that I have doesn't have the ability to set the 
> content type (and even if it did, sending just an HTML message is evil --  
> you have to send a text equivalent along with it. Indeed, many spam filters 
> substantially increase the spam score for messages where the text and HTML 
> have different contents -- it's important to get that right). I've never 
> needed that; the primary use I've had for this library is to send bounce 
> messages for undeliverable mail -- and that is always a plain text function 
> that does not copy much of the original message (if you include the original 
> message, spammers will bounce spam off of your mail server in order to use 
> it to originate the spam).
> 
> One can trivially send a text message in NC_SMTP using the simple send 
> function:
> 
>      NC_SMTP.Open (Session => My_Session,
>                                    IP => Target_Ip);
>      NC_SMTP.Send_Simple_Message (Session => My_Session,
>                                                               Sender => 
> "r...@rrsoftware.com",
>                                                               Recipient => 
> ad.....@ada-auth.org,
>                                                               Subject => 
> "Ada is great",
>                                                               The_Body => 
> ...);
>      NC_SMTP.Close (Session => My_Session);
> 
> Here, the body is a linked list of Unbounded_Strings, each string 
> representing a line (I won't show the construction of those - it should be 
> obvious). And Target_IP can be figured out by using the Lookup_Host_Info 
> function (this is the interface to DNS in Claw.Sockets and NC.Sockets).
> 
> There's probably some public library out there that does this stuff, but I 
> don't know anything about it.
> 
>                                      Randy.

So, basically, you're saying that this is impossible with the default AWS libraries?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Sending HTML e-mail
  2016-01-28  3:11         ` John Smith
@ 2016-01-28 21:42           ` Randy Brukardt
  0 siblings, 0 replies; 10+ messages in thread
From: Randy Brukardt @ 2016-01-28 21:42 UTC (permalink / raw)


"John Smith" <yoursurrogategod@gmail.com> wrote in message 
news:ece2119d-0969-4863-b5d7-fd521cbb1631@googlegroups.com...
...
>> There's probably some public library out there that does this stuff, but 
>> I
>> don't know anything about it.
>
> So, basically, you're saying that this is impossible with the default AWS 
> libraries?

No. I've never used AWS, I have no interest in writing code that is tied to 
GNAT.

                                Randy.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-01-28 21:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-24  4:25 Sending HTML e-mail John Smith
2016-01-24 16:12 ` Dennis Lee Bieber
2016-01-26  1:09   ` Randy Brukardt
2016-01-26 23:09     ` John Smith
2016-01-26 23:18       ` John Smith
2016-01-26 23:18       ` John Smith
2016-01-27  2:29         ` Dennis Lee Bieber
2016-01-28  0:14       ` Randy Brukardt
2016-01-28  3:11         ` John Smith
2016-01-28 21:42           ` Randy Brukardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox