我现在已解决了邮件发送的问题.可以发送附件和网页,现在碰到的问题是.
如果网页当中有图片就不行了.发过去的邮件没有图片.现在我想知道发送一个网页里面含有图片如何发送呢.

解决方案 »

  1.   

    图片放在网上,邮件正文用html代码写..显示那个图片..
    不知行得通不?
    个人愚见..不对甭见笑
      

  2.   

    我把代码贴出来给大家看一下.
    ------------------------HTML代码-----------------------------
    <%@ Page language="c#" Codebehind="Index.aspx.cs" AutoEventWireup="false" Inherits="MailSend.Index" validateRequest="false" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <HTML>
    <HEAD>
    <title>Index</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    <style type="text/css">
    TD { FONT-SIZE: 12px }
    INPUT { FONT-SIZE: 12px }
    BODY { FONT-SIZE: 12px }
    </style>
    <meta http-equiv="refresh" content="180;URL=Index.aspx">
    </HEAD>
    <body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">
    <form id="Form1" method="post" runat="server">
    <FONT face="宋体"></FONT>
    <table width="100%" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td background="images/bg-img.gif"><img src="images/bg-img1.jpg" width="949" height="80"></td>
    </tr>
    </table>
    <table width="800" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#cccccc">
    <tr bgcolor="#ffffff">
    <td width="97">&nbsp;邮箱账号:</td>
    <td>&nbsp;
    <asp:TextBox id="SendRen" runat="server" Width="200px">[email protected]</asp:TextBox>&nbsp;60秒后自动发送下一封邮件&nbsp; 
    [email protected]
    </td>
    </tr>
    <tr bgcolor="#ffffff">
    <td>&nbsp; 邮箱密码</td>
    <td>&nbsp;
    <asp:TextBox id="Password" runat="server" Width="200px">dayct215</asp:TextBox>&nbsp;includefile</td>
    </tr>
    <tr bgcolor="#ffffff">
    <td>&nbsp;S-M-T-P :</td>
    <td>&nbsp;
    <asp:TextBox id="SMTP" runat="server" Width="200px">mail.chancevip.com</asp:TextBox>&nbsp;mail.dreammould.com</td>
    </tr>
    <tr bgcolor="#ffffff">
    <td>&nbsp;收件人是:</td>
    <td>&nbsp;
    <asp:Label id="Label7" runat="server" Width="200px" Font-Bold="True" ForeColor="Red"></asp:Label></td>
    </tr>
    <tr bgcolor="#ffffff">
    <td>&nbsp;邮件标题:</td>
    <td>&nbsp;
    <asp:TextBox id="Title" runat="server" Width="650px"> 可以收得到不.</asp:TextBox></td>
    </tr>
    <tr>
    <td bgcolor="#ffffff">邮件内容:</td>
    <td bgcolor="#ffffff">&nbsp;<asp:TextBox id="Subject" runat="server" TextMode="MultiLine" Height="160px" Width="650px"></asp:TextBox></td>
    </tr>
    </table>
    <asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 120px; POSITION: absolute; TOP: 400px" runat="server"
    Text="邮件发送"></asp:Button>
    </form>
    </body>
    </HTML>
    ----------------------------------------CS源代码---------------------------------
    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;
    using System.Web.Mail;
    using System.IO;
    using System.Text;namespace MailSend
    {
    /// <summary>
    /// Index 的摘要说明。
    /// </summary>
    public class Index : System.Web.UI.Page
    {
    protected System.Web.UI.WebControls.TextBox Subject;
    protected System.Web.UI.WebControls.TextBox SMTP;
    protected System.Web.UI.WebControls.TextBox Password;
    protected System.Web.UI.WebControls.TextBox SendRen;
    protected System.Web.UI.WebControls.Label Label7;
    protected System.Web.UI.WebControls.Button Button1;
    protected System.Web.UI.WebControls.TextBox Title; private void Page_Load(object sender, System.EventArgs e)
    { } //发送邮件
    public void MailSend()
    {
    try
    {
    string MailAddress ="";
    MailAddress ="[email protected]";
    this.Label7.Text =MailAddress; MailMessage MM =new MailMessage(); //创建一个邮件发送器 MM.From =this.SendRen.Text; //发送方地址
    MM.To =MailAddress; //接收方地址
    MM.Subject =this.Title.Text; //邮件标题
    MM.BodyFormat =MailFormat.Html; //以HTML格式发送
    string Subject =this.Subject.Text.ToString().Replace("\"",""); //邮件内容
    string sAttach = @"images-0.jpg,images-1.jpg,images-2.jpg,images-3.jpg,images-4.jpg,images-5.jpg,images-6.jpg,images-7.jpg,images-8.jpg";
    foreach(string sSubstr in sAttach.Split(new char[]{','}))
    {
    MailAttachment attach = new MailAttachment(sSubstr);
    MM.Attachments.Add(attach);
    } MailAttachment a=new MailAttachment(Server.MapPath("bg-img1.jpg"));
    MM.Attachments.Add(a);
    MM.Body ="<img src=\"cid:bg-img1.jpg\" height=200 width=300>"+Subject;   //设置为需要.用户验证 
    MM.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");  
     
    //设置验证用户名(把emailaddress改为你的验证用户名) 
    MM.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.SendRen.Text); //设置验证密码(把password改为你的验证密码) 
    MM.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password.Text);  //邮件服务器地址 
    SmtpMail.SmtpServer = this.SMTP.Text;
    SmtpMail.Send(MM);
    }
    catch{}
    } #region Web 窗体设计器生成的代码
    override protected void OnInit(EventArgs e)
    {
    //
    // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
    //
    InitializeComponent();
    base.OnInit(e);
    }

    /// <summary>
    /// 设计器支持所需的方法 - 不要使用代码编辑器修改
    /// 此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {    
    this.Button1.Click += new System.EventHandler(this.Button1_Click);
    this.Load += new System.EventHandler(this.Page_Load); }
    #endregion private void Button1_Click(object sender, System.EventArgs e)
    {
    MailSend();
    } }
    }
      

  3.   

    现在我的代码可以发附件,没有问题.
    我想要实现的是把一个网页发过去,图片需要显示.如果在HTML的邮件当中显示我发过去的图片
      

  4.   

    注意图片路径,要用绝对路径,比如:http://www.aaa.com/img/1.gif
      

  5.   

    建议LZ用jmail吧!我用jmail发送(包括附件)都OK!
      

  6.   

    我现在用我的代码发附件也是正常的.只是我想要的目的是别人在OUTLOOK里面可以直接看到我的网页文档,网页文档当中有图片,我需要显示图片.
      

  7.   

    把你的邮件内容当作html处理就行了