Now that I've figured out how to send mail within our domain:
Dim test as new System.Net.Mail .SmtpClient
Dim nco as New
System.Net.Netw orkCredential(" mailaccount","p assword","domai n")
test.Credential s = nco
test.Host = "mailserver "
test.Send("ma** *******@domain. local","to***** @domain.local", "Subject","Mess age")
I am wondering how I could send mail in HTML format, or any other format
other than plain ol' text. If I try something like this:
Dim testtext as String = "<p style=""font-size:18pt"">Tes ting</p>"
test.Send("ma** *******@domain. local","to***** @domain.local", "Subject",testt ext)
The message body will end up being <p style="font-size:18pt">Test ing</p>
How can I fix this so I can send visually appealing messages?
Thanks,
Jim 4 1615
> I am wondering how I could send mail in HTML format, or any other format other than plain ol' text. If I try something like this: Dim testtext as String = "<p style=""font-size:18pt"">Tes ting</p>" test.Send("mail acco...@domain. local","toac... @domain.local", "Subject",testt ext) The message body will end up being <p style="font-size:18pt">Test ing</p> How can I fix this so I can send visually appealing messages?
You can use the System.Net.Mail .MailMessage class to construct a
message object, which can then be sent through an overload of
SmtpClient.Send . The MailMessage object has a four-parameter overloaded
constructor matching that for SmtpClient (i.e. To, From, Subject,
Body), but you can also manipulate the Body directly, and set
BodyIsHtml to be true to have the correct Content-Type set for the
message.
Paul Henderson wrote: I am wondering how I could send mail in HTML format, or any other format other than plain ol' text. If I try something like this: Dim testtext as String = "<p style=""font-size:18pt"">Tes ting</p>" test.Send("mail acco...@domain. local","toac... @domain.local", "Subject",testt ext) The message body will end up being <p style="font-size:18pt">Test ing</p> How can I fix this so I can send visually appealing messages?
You can use the System.Net.Mail .MailMessage class to construct a message object, which can then be sent through an overload of SmtpClient.Send . The MailMessage object has a four-parameter overloaded constructor matching that for SmtpClient (i.e. To, From, Subject, Body), but you can also manipulate the Body directly, and set BodyIsHtml to be true to have the correct Content-Type set for the message.
I couldn't quite figure out the code on this. I tried several things,
but still don't get any HTML. Here's what I ended up with that doesn't work.
Dim bodytest As New System.Net.Mail .MailMessage
bodytest.Body = "<p style=""font-size:20pt;"">Te st</p>"
bodytest.IsBody Html = True
Dim test As New System.Net.Mail .SmtpClient
Dim nco As New System.Net.Netw orkCredential(" useraccount", "password",
"domain")
test.Credential s = nco
test.Host = "mailserver "
test.Send("us** *******@hhs.loc al", "jm*******@doma in.local", "Test
Subject", bodytest.Body)
the send method of the Net.Mail.SmtpCl ient has two overloads, that I'm
aware of:
Send(string from, string recipients, string subject, string body)
And
Send(System.Net .Mail.MailMessa ge message)
If I just try:
test.Send(bodyt est)
An exception is thrown saying there is no "To" address specified.
I don't know how I would use the mail.mailmessag e within the Send(string
from, string recipients, string subject, string body). I i use it the
way I have in my code above, it shows the HTML instead of rendering it
properly.
> I don't know how I would use the mail.mailmessag e within the Send(string from, string recipients, string subject, string body). I i use it the way I have in my code above, it shows the HTML instead of rendering it properly.
Sorry, some rather bad explanation there by me ;-).
Try:
Dim bodytest As New
System.Net.Mail .MailMessage("u s*********@hhs. local",
"jm*******@doma in.local", "Test Subject", "<p
style=""font-size:20pt;"">Te st</p>")
bodytest.IsBody Html = True
Dim test As New System.Net.Mail .SmtpClient
Dim nco As New System.Net.Netw orkCredential(" useraccount", "password",
"domain")
test.Credential s = nco
test.Host = "mailserver "
test.Send(bodyt est)
Paul Henderson wrote: I don't know how I would use the mail.mailmessag e within the Send(string from, string recipients, string subject, string body). I i use it the way I have in my code above, it shows the HTML instead of rendering it properly.
Sorry, some rather bad explanation there by me ;-).
Try:
Dim bodytest As New System.Net.Mail .MailMessage("u s*********@hhs. local", "jm*******@doma in.local", "Test Subject", "<p style=""font-size:20pt;"">Te st</p>") bodytest.IsBody Html = True
Dim test As New System.Net.Mail .SmtpClient Dim nco As New System.Net.Netw orkCredential(" useraccount", "password", "domain") test.Credential s = nco test.Host = "mailserver " test.Send(bodyt est)
Perfect Paul. Thanks again for your persistent help! This mail stuff
will greatly improve the help desk ticket system I made up a while back.
Jim This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: prasanna |
last post by:
Hello
I tried to send mail from PHP in html format. But an ! mark appears
in mail body in Inbox. I tried to print body text on page before
sending mail and it does not show ! mark. I replaced ! mark from mail
body before passing it to mail() function but then also it adds ! mark
in mail body. Can you please tell me why this is happening?
Thanks
|
by: Francois Keyeux |
last post by:
hello everyone:
i have a web site built using vbasic active server scripting running on
iis (it works on either iis 50 and 60, but is designed for iis 50)
i know how to create a plain text email by creating a text file, with
content following certain format, and saving that file into the correct
'..\mailroot\pickup' folder, and it is working fine
|
by: Paul Turley |
last post by:
Does anyone have some sample code for sending an HTML formatted message
using CDONTS?
Thanks
RE: Sending HTML formatted mail using CDONTS
--
Paul Turley, MCSD, MCAD, MCT, MSF Practitioner, A+ Technician
|
by: Mr. x |
last post by:
Hello,
I am sending emails with Hebrew contents.
When receiving emails - I cannot see the Hebrew characters (it is not
outlook express configuration, because when receiving emails from friends -
I see hebrew, it is just sending by myself using *.aspx scripts).
In web.config I have the following :
<configuration>
<system.web>
|
by: Eduardo Rosa |
last post by:
Somebody knows how I queue email using .Net?
thanks a lot
| |
by: Anuradha |
last post by:
Dear All
How can i send mails using vb.net
Thanx all
|
by: Ray Booysen |
last post by:
Hi all
I'm sending email via ASP.NET in HTML mode. Each email has exactly one
attachment and I do have full access to the SMTP server. However, if I
send the email in HTML format, the framework reports the following
exception:
"System.Web.HttpException: Could not access 'CDO.Message' object. --->
System.Reflection.TargetInvocationException: Exception has been thrown
|
by: undbund |
last post by:
Hi I am creating a newsletter system. The software should run from
desktop computer (localhost) but be able to send email to anyone on
the internet. Can you guys give me some ideas on how to achieve this.
Thanks
|
by: virtualweb |
last post by:
Hello:
I need to send a bit of HTML and Javascrpt on the body of an email from my perl script in order to have the recipient get a link that will openup a new window with a PopUp.
For some reason instead of receiving the email with the HTML showing a link that will open up my PopUp... Im getting all the HTML tags and javasacript code printed on my email.
What am I doing wrong..??
Here is the code:
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |