Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 19-May-11 21:07pm
v4
Comments
[no name] 19-May-11 8:32am    
Could you please post your code so that we an tell you where you went wrong.
Prakash Sekhar 19-May-11 9:03am    
hi, can u tell me which code i need to post.
Dalek Dave 20-May-11 3:08am    
Edited for Grammar and Readability.

Hi,

Here is solution:

XML
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
 
Share this answer
 
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. :((
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900