在c#.net中发送简单邮件的SMTP错误? [英] SMTP error to send Simple mail in c#.net?

查看:177
本文介绍了在c#.net中发送简单邮件的SMTP错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码在我的应用程序中实现简单的邮件发送功能,但是在SmtpMail obj上调用Send方法时,它却出现了一些错误. 请帮忙... !!

I am trying to implement a simple mailing functionality into my application using the following code But it gives some Error while is invoke Send method on SmtpMail obj ..
Please help ...!!

private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MailMessage oMsg = new MailMessage();
                
                oMsg.From = "Mee@yahoo.in";
                
                oMsg.To = "You@hotmail.com";
                oMsg.Subject = "Send Using Test Mail";
                
                oMsg.BodyFormat = MailFormat.Text;

                string bodyText = textBox1.Text; // this textbox is part of the Application UI

                
                oMsg.Body = " Hey !!! This is meeee .. \n Sending this mail via Test Mail Application.. \n Cheers !!" + "\n " + bodyText;

                // ADD AN ATTACHMENT.
                // Path to attachment.
                String sFile = @"C:\Users\LUCKY\Desktop\Hello.txt";
                MailAttachment oAttch = new MailAttachment(sFile, MailEncoding.Base64);

                oMsg.Attachments.Add(oAttch);

               
                SmtpMail.SmtpServer = "localhost";// "smtp.gmail.com";
                SmtpMail.Send(oMsg);

                oMsg = null;
                oAttch = null;
            }
            catch (Exception ex)
            {
                //Console.WriteLine("{0} Exception caught.", ex);
                MessageBox.Show("Exception caught." +  ex.Message);
            }
        }



错误消息:传输无法连接到服务器.
我已经安装了IIS,并且已经将Windows7作为操作系统. IDE:VS2010.

附加问题:对于拥有单个GMAIL SMTP网关的该应用程序的不同用户,我们无法将发件人"字段设置为不同.有什么出路吗???


在此先感谢!!



the ERROR says : The Transport failed to connect to server.
I have IIS installed and i Have Windows7 as OS. IDE : VS 2010 .

Additional Question : There is no way we can have "From" field different for different users of this application which has my single GMAIL SMTP Gateway .?? Is there any way out ???


Thanks in Advance !!

推荐答案

有一个简单但有效的选项,可以使用GMAIL SMTP服务器通过类库(.dll文件)发送邮件.
该dll使您可以在几秒钟内通过附件将GMAIL帐户的邮件发送到任何其他SMTP服务器.

Codeproject不允许我上传文件.因此,您可以通过 manjumysore.k@gmail.com 寄给我,以便我将dll文件发送给您.

一切顺利.
There is a simple but effective option to send mails through a class library (.dll file) using GMAIL SMTP Server.

The dll enables you to send mails through your GMAIL account to any other SMTP servers in a fraction of seconds with attachments.

Codeproject doesnt allow me to upload a file. So, you can mail me at manjumysore.k@gmail.com so I could send you the dll file.

All the best.


您的应用程序无法连接到指定的邮件服务器

如果SmtpMail.SmtpServer指向"localhost"(或等效名称),请确保SMTP服务正在端口25上运行.
Your application cannot connect to the mail server specified

If SmtpMail.SmtpServer points to "localhost" (or the equivalent), be sure the SMTP Service is running on port 25.


查看此链接

http://www.codeproject.com/Questions/198066/error-in-smtp-sending-mail-reg.aspx

http://www.codeproject.com/Questions/198356/sending-of-auto-response-mails-reg.aspx


问候,
gowtham
check out this link

http://www.codeproject.com/Questions/198066/error-in-smtp-sending-mail-reg.aspx

http://www.codeproject.com/Questions/198356/sending-of-auto-response-mails-reg.aspx


regards,
gowtham


这篇关于在c#.net中发送简单邮件的SMTP错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆