Solved

change font mailSettings in asp.net 4

Posted on 2011-03-11
6
904 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

17 Experts available now in Live!

Get 1:1 Help Now