Click here to Skip to main content
15,921,382 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am using VS2010. I'm sending mail through asp.net.in my richtextbox m having text & image as body message.

When i send from asp.net ...in my gmail inbox image display like this

HTML
img alt="" src="data:image/png;base64,/9j/.................

Here is my code
C#
try
                {
                    MailAddress SendFrom = new MailAddress("sangeetha.rhythm14@gmail.com");
                   MailMessage message = new MailMessage();
                    message.From = SendFrom;
                    if (Txtcc.Text == "")
                    {
                    }
                    else
                    {
                        MailAddress SendCC = new MailAddress(Txtcc.Text);
                        message.CC.Add(SendCC);
                    }
                    if (Txtbcc.Text == "")
                    {

                    }
                    else
                    {
                        
                        MailAddress SendBCC = new MailAddress(Txtbcc.Text);
                        message.Bcc.Add(SendBCC);
                    }

                    message.Subject = txtSubject.Text;

                    message.SubjectEncoding = System.Text.Encoding.UTF8;
                    message.Body = txtBody.Content;
                    message.BodyEncoding = System.Text.Encoding.UTF8;
                     message.BodyEncoding = System.Text.Encoding.UTF8;
               message.IsBodyHtml = true;
                    string toemail = txtTo.Text;
                    string[] multi = toemail.Split(',');
                    foreach (string multiemailid in multi)
                    {
                        message.To.Add(new MailAddress(multiemailid));
                    }
                    if (fuAttachment.HasFile)
                    {
                        string FileName = Path.GetFileName(fuAttachment.PostedFile.FileName);
                        message.Attachments.Add(new Attachment(fuAttachment.PostedFile.InputStream, FileName));
                    }
                    SmtpClient smtp = new SmtpClient("smtp.gmail.com");
                    smtp.Port = 587;
                    smtp.Credentials = new System.Net.NetworkCredential("sangeetha.rhythm14@gmail.com", "password");
                    smtp.EnableSsl = true;
                    smtp.Send(message);
                   }
                catch (Exception ex)
                {
                }
                }


Please help me..
Posted
Updated 24-Mar-15 20:33pm
v3
Comments
[no name] 25-Mar-15 2:57am    
check this..click here
angelagolda 25-Mar-15 3:34am    
In richtextbox i will type some text and will paste image from my local drive. where as my text is showing in my gmail inbox but image display like this...<img alt="" src="data:image/png;base64,/9j...>

in ur code image is static (i will get image dynamic in richtextbox )and image not send in attachment.it must be in body of message.
// Add image attachment from local disk
Attachment oAttachment = oMail.AddAttachment( "d:\\test.gif" );

// Specifies the attachment as an embedded image
// contentid can be any string.
string contentID = "test001@host";
oAttachment.ContentID = contentID;
oMail.HtmlBody = "<html><body>this is a <img src=\"cid:"
+ contentID + "\"> embedded image.</body></html>";

Console.WriteLine("start to send email with embedded image...");
oSmtp.SendMail(oServer, oMail);
Console.WriteLine("email was sent successfully!");
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900