标签:http 使用 os strong 文件 io art 代码
1.添加JMail组件:在vs的解决方案资源管理器中,右键添加引用,选择浏览,选择jmail.dll文件,在Bin文件夹中就可以看到添加的JMail组件.
2.注册JMail组件:开始-->运行-->输入如:regsvr32 D:\DotNet相关插件和脚本\jmail.dll
Regsvr32 解释:
这个命令行工具将 dll 文件注册为注册表中的命令组成。
语法
regsvr32 【/u】 【/s】 【/n】 【/i【:cmdline】】 dllname
参数
/u
未注册服务器。
/s
指定 regsvr32 安静运行,且不显示任何消息框。
/n
指定不调用 DllRegisterServer。此选项必须与 /i 共同使用。
/i:cmdline
调用 DllInstall 将它传递到可选的 【cmdline】。在与 /u 共同使用时,它调用 dll 卸载。
dllname
指定要注册的 dll 文件名。
/?
在命令提示符显示帮助。
完成1,2部操作后,我们来编写代码:
界面参考:

- protected void btnTranSmit_Click(object sender, EventArgs e)
- {
- try
- {
-
- SendEmail(txtSender.Text, txtSenderName.Text, txtTransmitName.Text, txtTransmitPassword.Text, txtReceiver.Text, txtSubject.Text, txtContent.Text, txtServer.Text);
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
- private void SendEmail(String sender, String senderName, String TransmitName, String TransmitPassWord, String Receiver, String subject, String Content, String ServerHost)
- {
-
- MessageClass jMessage = new MessageClass();
-
-
- jMessage.Charset = "GB2312";
-
-
- jMessage.ISOEncodeHeaders = false;
-
-
- jMessage.From = sender;
-
-
- jMessage.FromName = senderName;
-
-
- jMessage.Subject = subject;
-
-
- jMessage.MailServerUserName = TransmitName;
-
-
- jMessage.MailServerPassWord = TransmitPassWord;
-
-
- jMessage.AddRecipient(Receiver, "", "");
-
-
- jMessage.Body = Content;
-
-
- if (fluAttachMent.HasFile)
- {
- String fileName = fluAttachMent.PostedFile.FileName;
-
- jMessage.AddAttachment(fileName, true, "");
- }
-
-
- if (jMessage.Send(ServerHost, false))
- {
- Response.Write("<script>alert(‘发送成功!‘);</script>");
- }
- else
- {
- Response.Write("<script>alert(‘发送失败!‘);</script>");
- }
-
- }
在项目中使用JMail发送邮件,布布扣,bubuko.com
在项目中使用JMail发送邮件
标签:http 使用 os strong 文件 io art 代码
原文地址:http://www.cnblogs.com/xiaochao12345/p/3880557.html