How to send image with email address included from local asp.net 4.0 web application

I created one email management system that can send email and save email as a draft. I have one big problem for sending email with images. I tried many times, but I could not cope with this. I just want to send the image with email turned on to the sender address.

here I store my mailbox as the ntext data type for the sql server, after which I just send it to the email address. here I put my screen shot for a general idea. how do I get the email body from ckeditor and the linqpad result, how do I store it.

This is the form in which I receive the body of the email:

enter image description here

linqpad, db:

enter image description here

" ", , , .

i , :

enter image description here

gmail:

From: shalinbgajjar7008@gmail.com 
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>

, , , .

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

-:

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);
    }

- , , html body . , ...

+4

Source: https://habr.com/ru/post/1569026/


All Articles