using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Net.Mail;
using System.IO;
using System.Net.Mime; 


namespace Postcards
{
    public partial class Form1 : Form
    {
        //String pathti;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //String ptt;
            MailMessage email = new MailMessage();
            openFileDialog1.Filter = "jpg files (*.jpg)|*.jpg";
            openFileDialog1.InitialDirectory = @"C:\\cinquin\\Postcards\\Postcards\\bin\\Debug";
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
               //MessageBox.Show(openFileDialog1.FileName);
            }
            email.To.Add(textBox3.Text);
            email.From = new MailAddress(textBox7.Text);
            email.Body = "<div style=\"font-family:Arial; color: " + textBox5.Text + "\"><img src=\"@@IMAGE@@\" alt=\"\" height=\"300\" width=\"300\"><br />Dear, " + textBox1.Text + "<br />" + textBox2.Text + "<br />" + textBox6.Text + ", <br />" + textBox4.Text + "<br /><br />";
            
            email.IsBodyHtml = true;
            //ptt = pathti;
            email.Subject = textBox8.Text; ;
            //mes.Body = "Hi! <img src='ele.jpeg' />";>
            //AlternateView ht = AlternateView.CreateAlternateViewFromString("<img style='width:50%; height: 50%;' src='cid:companylogo' /><div>Dear, " + textBox1.Text + "<br />" + textBox2.Text + "<br /> Sincerely, <br />" + textBox4.Text + "</div>", null, "text/html");
            string attachmentPath = openFileDialog1.FileName;
            string contentID = Path.GetFileName(attachmentPath).Replace(".", "") + "@zofm";

            // create the INLINE attachment
            Attachment inline = new Attachment(attachmentPath);
            inline.ContentDisposition.Inline = true;
            inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
            inline.ContentId = contentID;
            //inline.ContentType.MediaType = "image/png";
            inline.ContentType.Name = Path.GetFileName(attachmentPath);
            email.Attachments.Add(inline);

            email.Body = email.Body.Replace("@@IMAGE@@", "cid:" + contentID);
            
            
            var cl = new SmtpClient("smtp.gmail.com", 587)
            {
                Credentials = new NetworkCredential("romil@thesirohis.com", "ing2ing"),
                EnableSsl = true
            };
            cl.Send(email);



        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        
    }
}

That is the code. On email.body, how do I make the image the background image?

Change email.Body to email.Body = "<body background=\"@@IMAGE@@\"> </body>"

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.