Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

change font mailSettings in asp.net 4

Posted on 2011-03-11
6
Medium Priority
?
919 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Integration Management Part 2
Loops Section Overview

972 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