您的位置:程序门 -> .net技术 -> c#



关于发送邮件的问题?急


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


关于发送邮件的问题?急
发表于:2007-09-17 00:26:13 楼主
系统是net平台的,现在实现了发送邮件这个功能,但是我想直接在邮件中填加图片,邮件的格式我是用html的.如何实现?
发表于:2007-09-17 00:53:151楼 得分:0
获取cid
发表于:2007-09-17 01:31:422楼 得分:0
public   void   sendemail()
                {
                        mailmessage   mail   =   new   mailmessage();
                        mail.priority   =   mailpriority.high;
                        mail.from   =   "alonesword@gmail.com ";
                        mail.to   =   "hacker0722@163.com ";
                        mail.subject   =   "send   email   system   demo ";
                        mail.body   =   "just   for   test. ";
                        mail.bodyencoding   =   encoding.utf8;

                        //   authorization
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/sendusing ",   1);
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/sendemailaddress ",   mail.from);
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/smtpuserreplyemailaddress ",   mail.from);
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/smtpaccountname ",   "hacker0722@163.com ");
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/sendpassword ",   "cbf0921 ");
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate ",   1);
                        mail.fields.add( "http://schemas.microsoft.com/cdo/configuration/smtpserver ",   "smtp.163.com ");

                        smtpmail.smtpserver   =   "smtp.163.com ";
                        smtpmail.send(mail);
                }
发表于:2007-09-17 09:23:503楼 得分:0
邮件直接做成aspx文件,发送之前利用page的EXEC转换成html在发送。这个做法比较简单。
发表于:2007-09-17 10:29:134楼 得分:0
都行
发表于:2007-09-17 10:34:375楼 得分:0
protected   sub   button1_click(byval   sender   as   object,   byval   e   as   system.eventargs)
 
                dim   mg   as   mailmessage   =   new   mailmessage()
                mg.from   =   new   mailaddress( "chuxue1342@qq.com ")               '发件人邮箱
                mg.to.add( "chuxue1342@avl.com.cn ")                                                             '收件人邮箱
                mg.subject   =   "邮件测试 "                                                                                                       '邮件主题
                mg.body   =   "测试邮件,,内容为空 "                                                                               '邮件内容
                mg.bodyencoding   =   system.text.encoding.utf8                                 '内容编码
                mg.isbodyhtml   =   true                                                                                                               '是否支持html格式
                mg.priority   =   mailpriority.high                                                                                           '优先级别
                mg.attachments.add(new   attachment( "c:\ps.txt "))                                 '添加附件
                dim   smtp   as   smtpclient   =   new   smtpclient()
                smtp.deliverymethod   =   smtpdeliverymethod.network                           '邮件发送方式.这里通过网络
                smtp.host   =   "smtp.qq.com "                                                                                                     '邮件发送服务器
                smtp.credentials   =   new   networkcredential( "113620916 ",   "****** ")         '用户名跟密码
                try
                        smtp.send(mg)
                        label2.text   =   "ok "
                catch   ex   as   exception
                        label2.text   =   ex.tostring
                end   try
        end   sub
-------------------------------------------------------------------
记得imports   system.net.mail


快速检索

最新资讯
热门点击