0

Code to send email :

MailAddress addressFrom = new MailAddress("jack.du@e-iceblue.com", "Jack Du");
MailAddress addressTo = new MailAddress("susanwong32@outlook.com");
MailMessage message = new MailMessage(addressFrom, addressTo);

message.Date = DateTime.Now;
message.Subject = "Sending Email with HTML Body";
string htmlString = **my html code her to string convert**
                   ;   
message.BodyHtml = htmlString;

SmtpClient client= new SmtpClient();
client.Host = "smtp.outlook.com";
client.Port = 587;
client.Username = addressFrom.Address;
client.Password = "password";
client.ConnectionProtocols = ConnectionProtocols.Ssl;
client.SendOne(message);

Console.WriteLine("Sent Successfully!");
Console.Read();

I need to send email using Visual Basic .Net

Issue After Sending email i get my mail box having My text shows below my image , while the below html code shows working correct

Click to check my html code

braX
  • 11,506
  • 5
  • 20
  • 33
9to5ios
  • 5,319
  • 2
  • 37
  • 65
  • 1
    When it comes to email you need to code it using tables and inline CSS. Some email clients like Outlook don't like divs. Once you have inline CSS and tables your email will work properly. – Syfer Feb 02 '18 at 01:00
  • @Syfer thank i am checking for it.. – 9to5ios Feb 02 '18 at 07:55

1 Answers1

1

I will just use a background image in the container style, as follows

.container {
    position: relative;
    background: url('https://media.wmagazine.com/photos/585353e0d3b7a5db18f3a866/master/h_600,c_limit/GettyImages-105726097_master.jpg');
    text-align: center;
    color: orange;
    border: 1px solid #0d9ecf;
     width: 437px;
    height: 600px;
}

Instead of using the <img> tag.

Ricardo González
  • 1,385
  • 10
  • 19
  • please check it,as its showing fine in html but error in email – 9to5ios Feb 02 '18 at 07:54
  • Support for background images in emails are very patchy. For example background images don't work in Outlook 2007 and above. – Syfer Feb 02 '18 at 08:31
  • I tried it sending it to Hotmail, and it works if displayed inside Hotmail. In Outlook it may fail. Your best bet is to write text directly to the image before attaching it to the mail. https://stackoverflow.com/questions/6826921/write-text-on-an-image-in-c-sharp – Ricardo González Feb 03 '18 at 02:33