从IIS服务器发送电子邮件时出现问题. [英] Problem in Sending E-mail from IIS server.
问题描述
我必须从Web应用程序自动发送电子邮件.
我已将应用程序部署在IIS服务器中.
我将通过邮件获得一个链接,当我单击该链接时,必须执行一些操作,并且必须自动发送邮件.
如果从本地计算机检查邮件,则该邮件有效,但是,当从服务器进行测试时,该应用程序中出现服务器错误.
我也检查了应用程序的URL,很好.
谁能说出要做正确的事情需要做些什么?
在此先感谢.
我正在页面之间通过查询字符串传递值.
这是我在单击电子邮件中的链接时遇到的错误.
索引超出范围.必须为非负数并且小于集合的大小.
参数名称:index
解决方法如下:
MailMessage Ma =新的MailMessage(); Ma.From ="xx"; Ma.To ="yy"; Ma.Cc ="zz"; Ma.Subject =自动邮递员"; Ma.BodyFormat = MailFormat.Html; 字符串消息=" br < br > < br > ; 消息+ =自动邮件MSG"; 消息+ =" br < > "; Ma.Body =消息; SmtpMail.SmtpServer ="smtp.zzz"; SmtpMail.Send(Ma);
问候
Sathish K,
k7sathishsoft@gmail.com
您的代码在哪里? :((
我的猜测在这里
您的编码中有循环吗?
我认为您正在运行从0到计数的循环.尝试Count-1,因为计数是>最后索引.
示例:
for (int i = 0; i < dt.Rows.Count; i++) { //Code }应该是
for (int i = 0; i < dt.Rows.Count - 1; i++) { //Code }
您的编码中有数组吗?
检查索引,因为它应该基于数组大小
示例:
ArrayList alTest = new ArrayList(2);//Here array with 2 alTest[0] = "0"; alTest[1] = "1"; alTest[2] = "2";//But it''s the 3rd element it will raise error because array created with 2 sizes, so remove this line or increase the array size.
请从下次开始在您的问题中添加您的代码.:((
我发现了错误.我正在通过查询字符串传递5个值.同时检索它们我只得到4个值.我忘了在链接中传递第5个值.现在它可以正常工作了.感谢大家的答复.
I have to send e-mails automatically from my web application.
I have deployed the application in IIS server.
I will get a link through the mail, when I click the link some action has to happen and a mail has to be sent automatically.
The mail is working if I check it from my local machine, however, when I test it from the server I am getting Server Error in the application.
I have checked the URL of the application also, it is fine.
Can anyone tell what needs to be done to get it right?
Thanks in Advance.
I am passing the values through Query String between the pages.
This is the error I am getting while clicking the link in email.
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index解决方案Hi,
Here is solution:
MailMessage Ma = new MailMessage(); Ma.From = "xx"; Ma.To = "yy"; Ma.Cc = "zz"; Ma.Subject = "Auto Mailer"; Ma.BodyFormat = MailFormat.Html; string message = "<br>Dear All,<br><br>"; message += "Automailer MSG"; message += "<br>"; message += "Thank you for using Automailer<br>"; Ma.Body = message; SmtpMail.SmtpServer = "smtp.zzz"; SmtpMail.Send(Ma);
Regards
Sathish K,
k7sathishsoft@gmail.com
Where is your code? :((
My guesses here
Is any loop in your coding?
I think you are running the loop from 0 to the count. Try Count - 1, because the count is > last index.
Example:
for (int i = 0; i < dt.Rows.Count; i++) { //Code }It should be
for (int i = 0; i < dt.Rows.Count - 1; i++) { //Code }
Is any array in your coding?
Check the index because it should be based on array size
Example:
ArrayList alTest = new ArrayList(2);//Here array with 2 alTest[0] = "0"; alTest[1] = "1"; alTest[2] = "2";//But it''s the 3rd element it will raise error because array created with 2 sizes, so remove this line or increase the array size.
Please include your code in your question from next time. :((
I found out the mistake. I am passing 5 values through query string. while retrieving them i was getting only 4 values. i forgot to pass the 5th value in the link. Now it is working fine. Thanks to all for your replies.
这篇关于从IIS服务器发送电子邮件时出现问题.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!