通过交换服务器发送邮件 [英] Sending mail through exchange server

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

问题描述

protected void Button1_Click(object sender, EventArgs e)
   {
       SmtpClient smtpClient = new SmtpClient("exchangeServerHTTPS", 25);
       System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
       try
       {
           MailAddress fromAddress = new MailAddress("operations@test.com", "From Me");
           MailAddress toAddress = new MailAddress("faxsv@test.com", "To You");
           message.From = fromAddress;
           message.To.Add(toAddress);
           message.Subject = "Testing!";
           message.Body = "This is the body of a sample message";
           smtpClient.UseDefaultCredentials = true;
           System.Net.NetworkCredential nc = CredentialCache.DefaultNetworkCredentials;
           smtpClient.Credentials = (System.Net.ICredentialsByHost)nc.GetCredential("exchangeServerHTTPS", 25, "Basic");
           smtpClient.Send(message);

           lblmsg.Text = "Email sent.";
       }
       catch (Exception ex)
       {
           lblmsg.Text = "Coudn't send the message!\n  " + ex.Message;
       }

   }


我正在尝试此代码,但是在发送邮件时出错.
任何人都可以帮助我解决这个问题.........


i am trying this code but its getting error while sending mail.
any one will help me about this.................

推荐答案

因为您不会给我们任何反馈,所以我无法除了为您提供指向网页教程的链接之外,还可以通过其他任何方式帮助您:
http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx [ ^ ]

如果您有更多可以帮助我们了解您的问题的信息,请使用改进问题"按钮与我们联系.谢谢:)
Since you wont give us any feedback I cant help you in any other way than give you a link to a web page tutorial for doing this:
http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx[^]

If you have more information that can help us understand your problem pleas sher the information with us by using the Improve question button. Thanks :)


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

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