Click here to Skip to main content
15,074,394 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I'm used this code to send an Email Via embed images into body, and prevent from 'Display images below'[^] on target Emails
this is my code:
using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;
using System.Web.Services;
using System.Globalization;
using System.Net.Mail;
using System.Net.Mime;
using System.Net;

public partial class SendMail : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)


    protected void Send(object sender, EventArgs e)
        string subject = "CNet";
        string body = "";
        string from = "from";
        string password = "pwd";
        string server = "";
        string to = "";

            MailMessage mail = new MailMessage();
            mail.From = new MailAddress(from, subject);
            mail.Subject = "Test with Image";
            string Body = "Welcome to!!<br><BR>Online resource for .net articles.<BR><img alt=\"\" hspace=0 src=\"cid:imageId\" align=baseline border=0 >";

            AlternateView htmlView = AlternateView.CreateAlternateViewFromString(Body, null, "text/html");
            LinkedResource imagelink = new LinkedResource(Server.MapPath(".") + @"\pic.gif", "image/gif");
            imagelink.ContentId = "imageId";
            imagelink.TransferEncoding = System.Net.Mime.TransferEncoding.Base64;
            SmtpClient smtp = new SmtpClient();
            smtp.Port = 25;
            smtp.Host = server;
            smtp.Credentials = new NetworkCredential(from, password);
            //smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
        catch (Exception ex)
Updated 18-Feb-13 18:33pm
ridoy 19-Feb-13 2:49am
So what is the problem?what is your question?
shajarian_lover 19-Feb-13 5:26am
i want to prevent from display this Question on users mail, please check the following link and see the image.

actually, without the user click on the 'Display images below', the images that embed into mail body, can be seen.

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