邮件发送问题 我现在已解决了邮件发送的问题.可以发送附件和网页,现在碰到的问题是.如果网页当中有图片就不行了.发过去的邮件没有图片.现在我想知道发送一个网页里面含有图片如何发送呢. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 图片放在网上,邮件正文用html代码写..显示那个图片..不知行得通不?个人愚见..不对甭见笑 我把代码贴出来给大家看一下.------------------------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"> 邮箱账号:</td> <td> <asp:TextBox id="SendRen" runat="server" Width="200px">[email protected]</asp:TextBox> 60秒后自动发送下一封邮件 [email protected] </td> </tr> <tr bgcolor="#ffffff"> <td> 邮箱密码</td> <td> <asp:TextBox id="Password" runat="server" Width="200px">dayct215</asp:TextBox> includefile</td> </tr> <tr bgcolor="#ffffff"> <td> S-M-T-P :</td> <td> <asp:TextBox id="SMTP" runat="server" Width="200px">mail.chancevip.com</asp:TextBox> mail.dreammould.com</td> </tr> <tr bgcolor="#ffffff"> <td> 收件人是:</td> <td> <asp:Label id="Label7" runat="server" Width="200px" Font-Bold="True" ForeColor="Red"></asp:Label></td> </tr> <tr bgcolor="#ffffff"> <td> 邮件标题:</td> <td> <asp:TextBox id="Title" runat="server" Width="650px"> 可以收得到不.</asp:TextBox></td> </tr> <tr> <td bgcolor="#ffffff">邮件内容:</td> <td bgcolor="#ffffff"> <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(); } }} 现在我的代码可以发附件,没有问题.我想要实现的是把一个网页发过去,图片需要显示.如果在HTML的邮件当中显示我发过去的图片 注意图片路径,要用绝对路径,比如:http://www.aaa.com/img/1.gif 建议LZ用jmail吧!我用jmail发送(包括附件)都OK! 我现在用我的代码发附件也是正常的.只是我想要的目的是别人在OUTLOOK里面可以直接看到我的网页文档,网页文档当中有图片,我需要显示图片. 把你的邮件内容当作html处理就行了 如何计算下面的公式,C#中有现成的吗? c# winform datagirdView Checkbox选中问题 C# 子线程怎么操作主线程的组件?? Winform中如何动态添加一个Label到Panel中的指定坐标? 如何获取本机IE浏览器发送出去的Form表单信息 C#如何計算一段字符的打印寬度? 这种强悍的域名是怎么实现的? [求助]怎么让原来的类中出现自己的方法 哪位高人帮忙把下面的C语言改成C#啊 关于.Net提供的ListView控件在LargeIcon视图下的几个问题 数据库连接字符 Web 的GridView Bind 后如何编辑
不知行得通不?
个人愚见..不对甭见笑
------------------------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"> 邮箱账号:</td>
<td>
<asp:TextBox id="SendRen" runat="server" Width="200px">[email protected]</asp:TextBox> 60秒后自动发送下一封邮件
[email protected]
</td>
</tr>
<tr bgcolor="#ffffff">
<td> 邮箱密码</td>
<td>
<asp:TextBox id="Password" runat="server" Width="200px">dayct215</asp:TextBox> includefile</td>
</tr>
<tr bgcolor="#ffffff">
<td> S-M-T-P :</td>
<td>
<asp:TextBox id="SMTP" runat="server" Width="200px">mail.chancevip.com</asp:TextBox> mail.dreammould.com</td>
</tr>
<tr bgcolor="#ffffff">
<td> 收件人是:</td>
<td>
<asp:Label id="Label7" runat="server" Width="200px" Font-Bold="True" ForeColor="Red"></asp:Label></td>
</tr>
<tr bgcolor="#ffffff">
<td> 邮件标题:</td>
<td>
<asp:TextBox id="Title" runat="server" Width="650px"> 可以收得到不.</asp:TextBox></td>
</tr>
<tr>
<td bgcolor="#ffffff">邮件内容:</td>
<td bgcolor="#ffffff"> <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();
} }
}
我想要实现的是把一个网页发过去,图片需要显示.如果在HTML的邮件当中显示我发过去的图片