我不明白什么问题? [英] what is the problem ı dont understand?
本文介绍了我不明白什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我编写了一个用于发送邮件的共享点Web部件
我对Windows窗体应用程序使用相同的代码,Windows窗体应用程序发送邮件,但是sharepoint Web部件给我一个错误
低于此错误
I write a sharepoint web part for sending mail
I use same code for windows form application windows form application sending mail but sharepoint web part gives me a error
Below this error
Server Error in '/' Application.
The remote name could not be resolved: 'smtp host name'
下面的代码
code below
MailAddress ma = new MailAddress("mailadresss", "Admin");
MailMessage posta = new MailMessage();
posta.Body = TextBox2.Text;
posta.Subject = TextBox1.Text;
posta.To.Add(Label2.Text);
posta.From = ma;
posta.Priority = System.Net.Mail.MailPriority.High;
SmtpClient smtp = new SmtpClient();
smtp.Credentials = new System.Net.NetworkCredential("mailadress", "password");
smtp.Port = 25;
smtp.Host = "smtp host name";
smtp.Send(posta);
我无法理解相同的代码,但会给出错误
I don''t understand same code but givess error
推荐答案
这里可能发生了几件事.我建议的第一件事是使用异常处理来查找实际错误.或查看ULS日志以跟踪问题.确保服务器之间的通信没有中断.如果没有其他规定,SharePoint具有自己的发送电子邮件的机制, SPUtility.SendEmail [ ^ ]
There could be a couple of things happening here. The first thing I would suggest is to use exception handling to find the actual error. Or look at the ULS logs to trace the problem. Make sure the communication between the servers is not being disrupted. If all else, SharePoint has its own mechanism for sending email, SPUtility.SendEmail[^]
您需要将"smtp主机名"更改为有效的SMTP主机名(SMTP服务器).
祝你好运!
You need to change ''smtp host name'' to a valid SMTP host name (SMTP server).
Good luck!
这篇关于我不明白什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文