4

i have made one Email Management System that can send email and save email as draft. i have one bigger issue for sending email with images. i tried lot of time but i'm not done with it. I just want to send Image Enabled Email to sender address.

here i store my email body as ntext data type to sql server and after that i just send to mail address. here i put my form screen shot for general idea. how i retrieve email body from ckeditor and linqpad result how i store it.

this is the form how i retrieve email body :

enter image description here

this is linqpad screen shot how i store email body to db:

enter image description here

now just focus last record with title "Image Enabled Email" it's have email body with images now i just want this image to retrieved email.

i also include final output of finally receiver got email to this form :

enter image description here

and this is the original mail view from gmail :

From: [email protected] 
To:  
Date: Tue, 23 Dec 2014 19:30:58 +0530 
Subject: Image Enabled Email 

<table border="0" cellpadding="1" cellspacing="1" style="width: 700px;">
    <tbody>
        <tr>
            <td>
                <img alt="" src="/NewsLetter/images/Winter.jpg" style="width: 500px; height: 375px;" /></td>
            <td>
                <h3>
                    <span style="font-family:tahoma,geneva,sans-serif;"><span style="font-size:28px;">This is Image Enabled Mail For Testing </span></span></h3>
            </td>
        </tr>
    </tbody>
</table>
<p>
     </p>

I just want this image that was i was set in email body should be visible to receiver email address.

   -------------------- Upadted ------------------------

here i place my code to sending email from web application :

public static void SendReplyMail(string subject, string Host, string Port, string email, string password, string emails, string ccs, string bccs, string body, List<string> file_names)
    {
        MailMessage msg = new MailMessage();
        System.Net.Mail.SmtpClient client = Util.GetSmtpClient();
        msg.IsBodyHtml = true;
        client.Host = Host;
        System.Net.NetworkCredential basicauthenticationinfo = new System.Net.NetworkCredential(email, password);
        client.Port = int.Parse(Port);
        client.EnableSsl = true;
        client.UseDefaultCredentials = false;
        client.Credentials = basicauthenticationinfo;
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        msg.From = new MailAddress(email);
        if (emails.Contains(","))
        {
            string[] values1 = emails.Split(',');
            for (int i = 0; i < values1.Length; i++)
            {
                values1[i] = values1[i].Trim();
            }
            foreach (var item1 in values1)
            {
                msg.To.Add(new MailAddress(item1.ToString()));
            }
        }
        else
        {
            msg.To.Add(new MailAddress(emails));
        }
        if (!string.IsNullOrEmpty(ccs))
        {
            if (ccs.Contains(","))
            {
                string[] values2 = ccs.Split(',');
                for (int i = 0; i < values2.Length; i++)
                {
                    values2[i] = values2[i].Trim();
                }
                foreach (var item2 in values2)
                {
                    msg.CC.Add(new MailAddress(item2.ToString()));
                }
            }
            else
            {
                msg.CC.Add(new MailAddress(ccs));
            }
        }
        if (!string.IsNullOrEmpty(bccs))
        {
            if (bccs.Contains(","))
            {
                string[] values3 = bccs.Split(',');
                for (int i = 0; i < values3.Length; i++)
                {
                    values3[i] = values3[i].Trim();
                }
                foreach (var item3 in values3)
                {
                    msg.Bcc.Add(new MailAddress(item3.ToString()));
                }
            }
            else
            {
                msg.Bcc.Add(new MailAddress(bccs));
            }
        }
        msg.Subject = subject;
        msg.Body = body;
        using (DataClassesDataContext db = new DataClassesDataContext())
        {
            for (int i = 0; i < file_names.Count; i++)
            {
                Attachment mailAttachment = new Attachment(Path.Combine(HttpRuntime.AppDomainAppPath, "EmailFiles/" + db.Files.Where(f => f.File_name.Equals(file_names[i].Substring(0,15))).Select(f => f.File_name + f.File_ext).SingleOrDefault().ToString()));
                msg.Attachments.Add(mailAttachment);
            }
        }
        client.Send(msg);
    }

can some one have knowledge how to write image binary write when html body have image tag. please help me...

2
  • there is way to doing add images to hosted web site image folder and append it's full path to ckeditor images src in html content. but this is verry old method and time consuming is there way to dynamically send image enabled email. Commented Jan 17, 2015 at 7:20
  • i was herd about base64 encoding but how i do with my code can some one have idea. Commented Jan 17, 2015 at 11:16

1 Answer 1

3
+25

https://www.emailarchitect.net/easendmail/kb/vbnet.aspx?cat=8

That looks like it does what you want to do.

Sign up to request clarification or add additional context in comments.

3 Comments

can this works with multiple images found in html body if yes can u make code that suitable for my web application with asp.net 4.0 with c#.
So you don't want to know only how to do it, you want someone else to write all the code for you?
ok i want to fix it if i just only want to send this image embedded mail from just my local web application (not hosted) which one method suitable for my web application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.