Solved

change font mailSettings in asp.net 4

Posted on 2011-03-11
6
899 Views
Last Modified: 2012-05-11
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

0
Comment
Question by:aplimedia
  • 3
  • 3
6 Comments
 
LVL 10

Expert Comment

by:John Claes
ID: 35106629
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
0
 
LVL 10

Author Comment

by:aplimedia
ID: 35107240
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.
0
 
LVL 10

Expert Comment

by:John Claes
ID: 35107370
It might help to use

mymessage.BodyFormat = MailFormat.Html


0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 10

Author Comment

by:aplimedia
ID: 35107393
I have

Imports System.Net.Mail

not

Imports System.Web.Mail
0
 
LVL 10

Author Comment

by:aplimedia
ID: 35107636
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.
0
 
LVL 10

Accepted Solution

by:
John Claes earned 250 total points
ID: 35108459
Short :

mymessage.IsBodyHtml = True
mymessage.Body = "<span style=""font-family:courier;"">pretty colors!!</span>"  &  "Hello";


using styles and setting the Font family:

http://www.w3schools.com/CSS/pr_font_font-family.asp
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now