Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

change font mailSettings in asp.net 4

Posted on 2011-03-11
6
907 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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.…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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