Link to home
Start Free TrialLog in
Avatar of aplimedia
aplimediaFlag for Spain

asked on

change font mailSettings in asp.net 4

I want to send emails from my web. For this I use mailSettings in web.config
<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network" from="me@me.com">
        <network
           host="mail.me.com"
           port="25"
           userName="me@me.com"
           password="abcd" />
      </smtp>
    </mailSettings>
  </system.net>

In the button I use next code:

       Dim mymessage As MailMessage = New MailMessage()
        mymessage.Subject = "Hello"
        mymessage.Body = "Hola from me.com " 
         mymessage.From =   New MailAddress("me@me.com", "me.com")
        mymessage.To.Add(New MailAddress(TextBox1.Text))
        Dim mysmtpclient As SmtpClient = New SmtpClient()
        mysmtpclient.Send(mymessage)

everything works fine except I would like to change the font and font size of the text in my body email.

Is there any way to do this? Thanks

Avatar of John Claes
John Claes
Flag of Belgium image

I would suggest the folowing :

If you send the Mail like this it's a automaticaly send as a  Textmail and then it's not possible
Or you make it a HTML-Mail using simple tags

mymessage.Body = "<span style=""color:red;font-weight:bold;"">pretty colors!!</span>"
This way you can use styles or inner CSS in your mail

regards
poor beggar
Avatar of aplimedia

ASKER

If I change my code:
mymessage.Body = "Hello"

by

mymessage.Body = "<span style=""color:red;font-weight:bold;"">pretty colors!!</span>"  &  "Hello"

the mails I send looks like:

<span style="color:red;font-weight:bold;">pretty colors!!</span>Hello

is there anything else I have to add or change, thanks.
It might help to use

mymessage.BodyFormat = MailFormat.Html


I have

Imports System.Net.Mail

not

Imports System.Web.Mail
ok, I found the solution is to use:
 mymessage.IsBodyHtml = True

but somebody can send me an example of the code I need to use in html (I don´t know html)

just to send the text in courier new font

My problem is very easy I think, I need to send mails (I have it and it works) but the font must be courier new instead the default font.
ASKER CERTIFIED SOLUTION
Avatar of John Claes
John Claes
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial