完整发送邮件 [英] sending mail completly

查看:118
本文介绍了完整发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到问题,我听不懂,请帮助我.

我正在编写发送邮件"代码,但无法发送邮件.
我不知道问题出在哪里



I am facing a problem and I am not able to understand, please help me.

I am writing a Sending Mail code but I am not able send a mail.
I don''t know where is the problem



// Create a Mail Address Type Object for From Email
                 MailAddress sFrom = new MailAddress("xyz@mail.yahoo.com", "New Message");

               // Create a Mail Address Type Object for To Email
                MailAddress sTo = new MailAddress("abc@cherisys.com");

                // Create a Mail Message Type Object for Email and assign values to various properties, like subject, body, mail type.
                MailMessage MyMail = new MailMessage(sFrom, sTo);
                MyMail.Subject = "Subject Text";
                MyMail.Body = "Body Text";
                MyMail.IsBodyHtml = true;
                MyMail.BodyEncoding = Encoding.UTF8;

                //Create a SMTP client type object, Protocol responsible to send emails. And add the address of your email SMTP. Example of Yahoo added.

                SmtpClient SmtpMail = new SmtpClient("smtp.mail.yahoo.com");
                SmtpMail.EnableSsl = true;

                // Decline default credentials and add yours. Your Email (From Email) & Password.
                SmtpMail.UseDefaultCredentials = false;
                SmtpMail.Credentials = new System.Net.NetworkCredential("xyz@mail.yahoo.com", "xyzpassword");
    
                // Now send email
                try
                {
                    SmtpMail.Send(MyMail);
                }
                catch (Exception o) { }

推荐答案


检查此提示/技巧
使用C#发送带有或不带有附件的电子邮件:通用例程. [ ^ ]
Check this Tip/Trick
Sending an Email in C# with or without attachments: generic routine.[^]


请检查以下网址,

使用Google Apps发送邮件

如果您是从gmail或google应用发送电子邮件,则所有已发送的电子邮件都将存储在gmail的已发送邮件中.
希望这对您有帮助...
Please check the following url,

Send mail using Google Apps

If you are sending email from gmail or google apps than all sent email would be store in the sent items of the gmail.
Hope this may help you...


这篇关于完整发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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