sending html formatted mail through vb .net | | |
The following code works fine:
Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
htmstring = sr.ReadToEnd()
msg.Body = htmstring
msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
However, if the htm file has images, they do not go along with the text
stream. How can I include the images that the htm file uses?
Thanks for any help.
Bernie Yaeger | | | | re: sending html formatted mail through vb .net
Bernie,
Images would have to be embedded in attachments of the mail message itself,
if you look at spam, they don't include the images in the message itself,
but on a public webserver outside of it.
To send the messages themselves with images is a huge bandwidth hog on mail
servers.
"Bernie Yaeger" <berniey@cherwellinc.com> wrote in message
news:eILk#Vw$DHA.1464@tk2msftngp13.phx.gbl...[color=blue]
> The following code works fine:
> Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
>
> htmstring = sr.ReadToEnd()
>
> msg.Body = htmstring
>
> msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
>
> However, if the htm file has images, they do not go along with the text
> stream. How can I include the images that the htm file uses?
>
> Thanks for any help.
>
> Bernie Yaeger
>
>
>
>[/color] | | | | re: sending html formatted mail through vb .net
Bernie,
* "Bernie Yaeger" <berniey@cherwellinc.com> scripsit:[color=blue]
> Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
>
> htmstring = sr.ReadToEnd()
>
> msg.Body = htmstring
>
> msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
>
> However, if the htm file has images, they do not go along with the text
> stream. How can I include the images that the htm file uses?[/color]
I didn't test it, but maybe it will work better with Indy:
<http://www.indyproject.org/indy.html>.
--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed! | | | | re: sending html formatted mail through vb .net
From a practical standpoint doesn't this look like streamreader is the
cause?
I could be out to lunch but it would have to "read the stream" and notice
there was a reference to a supported graphic type and decide to load that
too despite it being in a "different" stream (does it open it read-only?)
and then it encounters what looks like a reference to a 20 minute video file
and so it reads that too. :-)
I'm not certain I want streamreader to be that clever,
Tom
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote...[color=blue]
> Bernie,
>
> * "Bernie Yaeger" <berniey@cherwellinc.com> scripsit:[color=green]
> > Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
> >
> > htmstring = sr.ReadToEnd()
> >
> > msg.Body = htmstring
> >
> > msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
> >
> > However, if the htm file has images, they do not go along with the text
> > stream. How can I include the images that the htm file uses?[/color]
>
> I didn't test it, but maybe it will work better with Indy:
> <http://www.indyproject.org/indy.html>.
>
> --
> Herfried K. Wagner [MVP]
> <http://dotnet.mvps.org/>
> Website Address Changed![/color] | | | | re: sending html formatted mail through vb .net
Tx Herfried - looks like an interesting component.
Bernie
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:c1tqfu$1mtksq$1@ID-208219.news.uni-berlin.de...[color=blue]
> Bernie,
>
> * "Bernie Yaeger" <berniey@cherwellinc.com> scripsit:[color=green]
> > Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
> >
> > htmstring = sr.ReadToEnd()
> >
> > msg.Body = htmstring
> >
> > msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
> >
> > However, if the htm file has images, they do not go along with the text
> > stream. How can I include the images that the htm file uses?[/color]
>
> I didn't test it, but maybe it will work better with Indy:
> <http://www.indyproject.org/indy.html>.
>
> --
> Herfried K. Wagner [MVP]
> <http://dotnet.mvps.org/>
> Website Address Changed![/color] | | | | re: sending html formatted mail through vb .net
Thanks CJ - I think I have to answer from your suggestions - I can call each
image from an internet site - eg, http:// etc - where the images reside.
Thanks again,
Bernie
"CJ Taylor" <cj@herfriedslovechild.org> wrote in message
news:cFs0c.425394$I06.4763428@attbi_s01...[color=blue]
> Bernie,
>
> Images would have to be embedded in attachments of the mail message[/color]
itself,[color=blue]
> if you look at spam, they don't include the images in the message itself,
> but on a public webserver outside of it.
>
> To send the messages themselves with images is a huge bandwidth hog on[/color]
mail[color=blue]
> servers.
>
>
>
> "Bernie Yaeger" <berniey@cherwellinc.com> wrote in message
> news:eILk#Vw$DHA.1464@tk2msftngp13.phx.gbl...[color=green]
> > The following code works fine:
> > Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
> >
> > htmstring = sr.ReadToEnd()
> >
> > msg.Body = htmstring
> >
> > msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
> >
> > However, if the htm file has images, they do not go along with the text
> > stream. How can I include the images that the htm file uses?
> >
> > Thanks for any help.
> >
> > Bernie Yaeger
> >
> >
> >
> >[/color]
>
>[/color] | | | | re: sending html formatted mail through vb .net
* "Tom Leylan" <gee@iamtiredofspam.com> scripsit:[color=blue]
> From a practical standpoint doesn't this look like streamreader is the
> cause?[/color]
Yes and no. The HTML file doesn't include the graphics files, it only
references them.
[color=blue]
> I could be out to lunch but it would have to "read the stream" and notice
> there was a reference to a supported graphic type and decide to load that
> too despite it being in a "different" stream (does it open it read-only?)
> and then it encounters what looks like a reference to a 20 minute video file
> and so it reads that too. :-)
>
> I'm not certain I want streamreader to be that clever,[/color]
'StreamReader' isn't that clever, but you can provide a class
'TomsToolbox.HtmlStreamReader' or something similar :-).
--
Herfried K. Wagner [MVP]
<http://dotnet.mvps.org/>
Website Address Changed! | | | | re: sending html formatted mail through vb .net
Perhaps I misunderstood...
Is there a replacement for StreamReader in the Indy library which analyzes
the file it is reading and decides which files to imbed? It could be I have
it entirely wrong but it seems... well let me use the term "unlikely."
If it has such a feature would you let us know?
Again... I'm probably phrasing things wrong. What makes you think that Indy
might be able to produce alternative results... that might be what I'm
trying to ask.
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:c1tto0$1mjnft$1@ID-208219.news.uni-berlin.de...[color=blue]
> * "Tom Leylan" <gee@iamtiredofspam.com> scripsit:[color=green]
> > From a practical standpoint doesn't this look like streamreader is the
> > cause?[/color]
>
> Yes and no. The HTML file doesn't include the graphics files, it only
> references them.
>[color=green]
> > I could be out to lunch but it would have to "read the stream" and[/color][/color]
notice[color=blue][color=green]
> > there was a reference to a supported graphic type and decide to load[/color][/color]
that[color=blue][color=green]
> > too despite it being in a "different" stream (does it open it[/color][/color]
read-only?)[color=blue][color=green]
> > and then it encounters what looks like a reference to a 20 minute video[/color][/color]
file[color=blue][color=green]
> > and so it reads that too. :-)
> >
> > I'm not certain I want streamreader to be that clever,[/color]
>
> 'StreamReader' isn't that clever, but you can provide a class
> 'TomsToolbox.HtmlStreamReader' or something similar :-).
>
> --
> Herfried K. Wagner [MVP]
> <http://dotnet.mvps.org/>
> Website Address Changed![/color] | | | | re: sending html formatted mail through vb .net
Exactly.
no problem,.
CJ
"Bernie Yaeger" <berniey@cherwellinc.com> wrote in message
news:u3pTezx$DHA.620@TK2MSFTNGP11.phx.gbl...[color=blue]
> Thanks CJ - I think I have to answer from your suggestions - I can call[/color]
each[color=blue]
> image from an internet site - eg, http:// etc - where the images reside.
>
> Thanks again,
>
> Bernie
>
> "CJ Taylor" <cj@herfriedslovechild.org> wrote in message
> news:cFs0c.425394$I06.4763428@attbi_s01...[color=green]
> > Bernie,
> >
> > Images would have to be embedded in attachments of the mail message[/color]
> itself,[color=green]
> > if you look at spam, they don't include the images in the message[/color][/color]
itself,[color=blue][color=green]
> > but on a public webserver outside of it.
> >
> > To send the messages themselves with images is a huge bandwidth hog on[/color]
> mail[color=green]
> > servers.
> >
> >
> >
> > "Bernie Yaeger" <berniey@cherwellinc.com> wrote in message
> > news:eILk#Vw$DHA.1464@tk2msftngp13.phx.gbl...[color=darkred]
> > > The following code works fine:
> > > Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")
> > >
> > > htmstring = sr.ReadToEnd()
> > >
> > > msg.Body = htmstring
> > >
> > > msg.BodyFormat = MailFormat.Html ' as opposed to mailformat.text
> > >
> > > However, if the htm file has images, they do not go along with the[/color][/color][/color]
text[color=blue][color=green][color=darkred]
> > > stream. How can I include the images that the htm file uses?
> > >
> > > Thanks for any help.
> > >
> > > Bernie Yaeger
> > >
> > >
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: sending html formatted mail through vb .net
Hi Tom,
Frankly, I love your idea - but the streamreader (or component) would have
to be pretty smart to do what you suggest. But the more I think of it, yes,
it should be able to! Great idea.
Bernie
"Tom Leylan" <gee@iamtiredofspam.com> wrote in message
news:e%23sbxmy$DHA.1792@TK2MSFTNGP12.phx.gbl...[color=blue]
> Perhaps I misunderstood...
>
> Is there a replacement for StreamReader in the Indy library which analyzes
> the file it is reading and decides which files to imbed? It could be I[/color]
have[color=blue]
> it entirely wrong but it seems... well let me use the term "unlikely."
>
> If it has such a feature would you let us know?
>
> Again... I'm probably phrasing things wrong. What makes you think that[/color]
Indy[color=blue]
> might be able to produce alternative results... that might be what I'm
> trying to ask.
>
>
>
> "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> news:c1tto0$1mjnft$1@ID-208219.news.uni-berlin.de...[color=green]
> > * "Tom Leylan" <gee@iamtiredofspam.com> scripsit:[color=darkred]
> > > From a practical standpoint doesn't this look like streamreader is the
> > > cause?[/color]
> >
> > Yes and no. The HTML file doesn't include the graphics files, it only
> > references them.
> >[color=darkred]
> > > I could be out to lunch but it would have to "read the stream" and[/color][/color]
> notice[color=green][color=darkred]
> > > there was a reference to a supported graphic type and decide to load[/color][/color]
> that[color=green][color=darkred]
> > > too despite it being in a "different" stream (does it open it[/color][/color]
> read-only?)[color=green][color=darkred]
> > > and then it encounters what looks like a reference to a 20 minute[/color][/color][/color]
video[color=blue]
> file[color=green][color=darkred]
> > > and so it reads that too. :-)
> > >
> > > I'm not certain I want streamreader to be that clever,[/color]
> >
> > 'StreamReader' isn't that clever, but you can provide a class
> > 'TomsToolbox.HtmlStreamReader' or something similar :-).
> >
> > --
> > Herfried K. Wagner [MVP]
> > <http://dotnet.mvps.org/>
> > Website Address Changed![/color]
>
>[/color] | | | | re: sending html formatted mail through vb .net
Hi Bernie,
I fear that I've been misunderstood. No problem though as decades of
misunderstandings have made me quite immune to this :-) But... how would it
"know" which things in the text file (and don't for a moment think that a
file with an HTM extension isn't a text file) should read using the same
settings as it used to read the text file?
You can't read any old graphics format with the same settings as you read a
text file. They aren't the same format, you may not have the proper
permissions, you didn't explain what to do if one of the potentially many
"subfiles" turns out to not be available, etc. Try it from this
direction... it encounters ".pdf" as as an extension... and? What do you
hope it will do? Use your copy of the .pdf reader, the one you think you
the client has? Some version in cyberspace? It had better fail just to
behave normally :-)
It not only can't if it ever could it shouldn't... :-)
I'm still trying to figure out why Herfried thought that some other TCP/IP
library would make a difference. It's not a bad idea, I'm just wondering
how people's minds work. These are computers... why not suppose that cars
know where we want to go and have them simply drive us there?
"Bernie Yaeger" <berniey@cherwellinc.com> wrote in message
news:uSrvQez$DHA.2216@TK2MSFTNGP10.phx.gbl...[color=blue]
> Hi Tom,
>
> Frankly, I love your idea - but the streamreader (or component) would have
> to be pretty smart to do what you suggest. But the more I think of it,[/color]
yes,[color=blue]
> it should be able to! Great idea.
>
> Bernie
>
> "Tom Leylan" <gee@iamtiredofspam.com> wrote in message
> news:e%23sbxmy$DHA.1792@TK2MSFTNGP12.phx.gbl...[color=green]
> > Perhaps I misunderstood...
> >
> > Is there a replacement for StreamReader in the Indy library which[/color][/color]
analyzes[color=blue][color=green]
> > the file it is reading and decides which files to imbed? It could be I[/color]
> have[color=green]
> > it entirely wrong but it seems... well let me use the term "unlikely."
> >
> > If it has such a feature would you let us know?
> >
> > Again... I'm probably phrasing things wrong. What makes you think that[/color]
> Indy[color=green]
> > might be able to produce alternative results... that might be what I'm
> > trying to ask.
> >
> >
> >
> > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> > news:c1tto0$1mjnft$1@ID-208219.news.uni-berlin.de...[color=darkred]
> > > * "Tom Leylan" <gee@iamtiredofspam.com> scripsit:
> > > > From a practical standpoint doesn't this look like streamreader is[/color][/color][/color]
the[color=blue][color=green][color=darkred]
> > > > cause?
> > >
> > > Yes and no. The HTML file doesn't include the graphics files, it only
> > > references them.
> > >
> > > > I could be out to lunch but it would have to "read the stream" and[/color]
> > notice[color=darkred]
> > > > there was a reference to a supported graphic type and decide to load[/color]
> > that[color=darkred]
> > > > too despite it being in a "different" stream (does it open it[/color]
> > read-only?)[color=darkred]
> > > > and then it encounters what looks like a reference to a 20 minute[/color][/color]
> video[color=green]
> > file[color=darkred]
> > > > and so it reads that too. :-)
> > > >
> > > > I'm not certain I want streamreader to be that clever,
> > >
> > > 'StreamReader' isn't that clever, but you can provide a class
> > > 'TomsToolbox.HtmlStreamReader' or something similar :-).
> > >
> > > --
> > > Herfried K. Wagner [MVP]
> > > <http://dotnet.mvps.org/>
> > > Website Address Changed![/color]
> >
> >[/color]
>
>[/color] | | | | re: sending html formatted mail through vb .net
Hi Bernie,
[color=blue]
> The following code works fine:
> Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")[/color]
Did you test this also with webpages with frames?
Just curious if this works, I am asuming that this does not work also?
Cor | | | | re: sending html formatted mail through vb .net
Hi Tom,
Why so difficult? Parsing a string isn't all that hard. How many key
strings need the component parse - .pdf, .gif, .png, .jpg - then, too,
<http, <href and various other tags, all of which is done now by the html
spec.
No, you're not giving yourself enough credit :-)
Bernie
"Tom Leylan" <gee@iamtiredofspam.com> wrote in message
news:umMNKqz$DHA.3712@tk2msftngp13.phx.gbl...[color=blue]
> Hi Bernie,
>
> I fear that I've been misunderstood. No problem though as decades of
> misunderstandings have made me quite immune to this :-) But... how would[/color]
it[color=blue]
> "know" which things in the text file (and don't for a moment think that a
> file with an HTM extension isn't a text file) should read using the same
> settings as it used to read the text file?
>
> You can't read any old graphics format with the same settings as you read[/color]
a[color=blue]
> text file. They aren't the same format, you may not have the proper
> permissions, you didn't explain what to do if one of the potentially many
> "subfiles" turns out to not be available, etc. Try it from this
> direction... it encounters ".pdf" as as an extension... and? What do you
> hope it will do? Use your copy of the .pdf reader, the one you think you
> the client has? Some version in cyberspace? It had better fail just to
> behave normally :-)
>
> It not only can't if it ever could it shouldn't... :-)
>
> I'm still trying to figure out why Herfried thought that some other TCP/IP
> library would make a difference. It's not a bad idea, I'm just wondering
> how people's minds work. These are computers... why not suppose that cars
> know where we want to go and have them simply drive us there?
>
>
> "Bernie Yaeger" <berniey@cherwellinc.com> wrote in message
> news:uSrvQez$DHA.2216@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi Tom,
> >
> > Frankly, I love your idea - but the streamreader (or component) would[/color][/color]
have[color=blue][color=green]
> > to be pretty smart to do what you suggest. But the more I think of it,[/color]
> yes,[color=green]
> > it should be able to! Great idea.
> >
> > Bernie
> >
> > "Tom Leylan" <gee@iamtiredofspam.com> wrote in message
> > news:e%23sbxmy$DHA.1792@TK2MSFTNGP12.phx.gbl...[color=darkred]
> > > Perhaps I misunderstood...
> > >
> > > Is there a replacement for StreamReader in the Indy library which[/color][/color]
> analyzes[color=green][color=darkred]
> > > the file it is reading and decides which files to imbed? It could be[/color][/color][/color]
I[color=blue][color=green]
> > have[color=darkred]
> > > it entirely wrong but it seems... well let me use the term "unlikely."
> > >
> > > If it has such a feature would you let us know?
> > >
> > > Again... I'm probably phrasing things wrong. What makes you think[/color][/color][/color]
that[color=blue][color=green]
> > Indy[color=darkred]
> > > might be able to produce alternative results... that might be what I'm
> > > trying to ask.
> > >
> > >
> > >
> > > "Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
> > > news:c1tto0$1mjnft$1@ID-208219.news.uni-berlin.de...
> > > > * "Tom Leylan" <gee@iamtiredofspam.com> scripsit:
> > > > > From a practical standpoint doesn't this look like streamreader is[/color][/color]
> the[color=green][color=darkred]
> > > > > cause?
> > > >
> > > > Yes and no. The HTML file doesn't include the graphics files, it[/color][/color][/color]
only[color=blue][color=green][color=darkred]
> > > > references them.
> > > >
> > > > > I could be out to lunch but it would have to "read the stream" and
> > > notice
> > > > > there was a reference to a supported graphic type and decide to[/color][/color][/color]
load[color=blue][color=green][color=darkred]
> > > that
> > > > > too despite it being in a "different" stream (does it open it
> > > read-only?)
> > > > > and then it encounters what looks like a reference to a 20 minute[/color]
> > video[color=darkred]
> > > file
> > > > > and so it reads that too. :-)
> > > > >
> > > > > I'm not certain I want streamreader to be that clever,
> > > >
> > > > 'StreamReader' isn't that clever, but you can provide a class
> > > > 'TomsToolbox.HtmlStreamReader' or something similar :-).
> > > >
> > > > --
> > > > Herfried K. Wagner [MVP]
> > > > <http://dotnet.mvps.org/>
> > > > Website Address Changed!
> > >
> > >[/color]
> >
> >[/color]
>
>[/color] | | | | re: sending html formatted mail through vb .net
Hi Cor,
No; I haven't tested with frames; interesting idea, because that would
require at least the frameset page and the regular page.
Bernie
"Cor" <non@non.com> wrote in message
news:uvzznt1$DHA.1548@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi Bernie,
>[color=green]
> > The following code works fine:
> > Dim sr As StreamReader = New StreamReader("c:\htdogpro\bhome.htm")[/color]
>
> Did you test this also with webpages with frames?
>
> Just curious if this works, I am asuming that this does not work also?
>
> Cor
>
>
>[/color] | | | | re: sending html formatted mail through vb .net
Bernie... I appreciate the vote of confidence :-)
Parsing isn't as easy as you make out but you're asking StreamReader to do
it. It might make it troublesome to read a stream that happens to contain
what could be interpreted as a reference to a graphics image. Generally
speaking you would want it to recognize every format that could conceivably
be represented on an HTML page... I'll quote from the W3C site: http://www.w3.org/Graphics/
"There is no limit in the Web specifications to the graphical formats that
can be used on the Web. You just need a MIME type so that the format is
labelled correctly for transfer across the Web, and so that a suitable
viewer (if one exists) can be located at the other end."
I'm not against somebody offering a library to do such a thing but I would
be a little concerned about a basic StreamReader class trying to handle it
all. Remember it isn't just about images. I'd have to locate a video and
audio formats page but I'm sure you get the point :-)
"Bernie Yaeger" <berniey@cherwellinc.com> wrote...
[color=blue]
> Why so difficult? Parsing a string isn't all that hard. How many key
> strings need the component parse - .pdf, .gif, .png, .jpg - then, too,
> <http, <href and various other tags, all of which is done now by the html
> spec.
>
> No, you're not giving yourself enough credit :-)
>
> Bernie[/color] |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,366 network members.
|