通过vb .net发送html格式的邮件 [英] sending html formatted mail through vb .net

查看:97
本文介绍了通过vb .net发送html格式的邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下代码可以正常工作:

Dim sr As StreamReader = New StreamReader(" c:\\\\\\\\\\\\\\\\\\\\ b htmstring = sr.ReadToEnd()

msg.Body = htmstring

msg.BodyFormat = MailFormat.Html''而不是mailformat .text


但是,如果htm文件有图像,则它们不会与文本

流一起使用。如何包含htm文件使用的图像?


感谢您的帮助。


Bernie Yaeger

解决方案

伯尼,


图像必须嵌入邮件消息本身的附件中,

如果你看垃圾邮件,他们不会在邮件本身中包含图片,

但是在它之外的公共网络服务器上。


使用图像发送消息本身对邮件来说是一个巨大的带宽负担。


" Bernie Yaeger" <是***** @ cherwellinc.com>在消息中写道

news:eI ************** @ tk2msftngp13.phx.gbl ...

以下代码工作正常:
Dim sr As StreamReader = New StreamReader(" c:\ htdogpro\bhome.htm")

htmstring = sr.ReadToEnd()

msg.Body = htmstring

msg.BodyFormat = MailFormat.Html''而不是mailformat.text

然而,如果htm文件有图像,它们不会同时出现用文本
流。如何包含htm文件使用的图像?

感谢您的帮助。

Bernie Yaeger



Bernie,


*" Bernie Yaeger" <是***** @ cherwellinc.com> scripsit:

Dim sr As StreamReader = New StreamReader(" c:\ htdogpro\bhome.htm")

htmstring = sr.ReadToEnd()

msg.Body = htmstring
msg.BodyFormat = MailFormat.Html''而不是mailformat.text
然而,如果htm文件有图像,他们不喜欢文字流。如何包含htm文件使用的图像?




我没有测试它,但也许它可以与Indy更好地工作:

< http://www.indyproject.org/indy.html>。


-

Herfried K. Wagner [MVP]

< http://dotnet.mvps.org/>

网站地址已更改!


来自实际的立场并不像流读者那样的原因是什么?


我可以出去吃午饭但它必须读取流 ;并注意

有一个支持图形类型的引用,并决定加载

,尽管它处于不同状态。流(它是否以只读方式打开?)

然后它遇到的内容看起来像是对20分钟视频文件的引用

所以它也会读取它。 :-)


我不确定我想让streamreader变得那么聪明,

Tom


Herfried K. Wagner [MVP]" <喜*************** @ gmx.at>写了...

Bernie,

*Bernie Yaeger <是***** @ cherwellinc.com> scripsit:

Dim sr As StreamReader = New StreamReader(" c:\ htdogpro\bhome.htm")

htmstring = sr.ReadToEnd()

msg.Body = htmstring
msg.BodyFormat = MailFormat.Html''而不是mailformat.text
然而,如果htm文件有图像,他们不喜欢文字流。我如何包含htm文件使用的图像?



我没有测试它,但也许它可以与Indy更好地工作:
< http:/ /www.indyproject.org/indy.html>。

- Herfried K. Wagner [MVP]
< http://dotnet.mvps.org/> ;
网站地址已更改!



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


解决方案

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" <be*****@cherwellinc.com> wrote in message
news:eI**************@tk2msftngp13.phx.gbl...

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



Bernie,

* "Bernie Yaeger" <be*****@cherwellinc.com> scripsit:

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?



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!


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]" <hi***************@gmx.at> wrote...

Bernie,

* "Bernie Yaeger" <be*****@cherwellinc.com> scripsit:

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?



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!



这篇关于通过vb .net发送html格式的邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆