Click here to Skip to main content
16,012,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have the following code written in a class file which is suppose to fire a mail from the ftp site (which it was firing earlier) but now it has stopped so kindly suggest some solution. Code is as under:

*****************************************************************
C#
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Web.Mail;
using System.Data.SqlClient;
using System.Reflection;
using ASPEMAILLib;

/// <summary>
/// Summary description for CompMail
/// </summary>

public class CompMail
{
    public CompMail()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public void fireMail(int comp_seqid)
    {
        MailMessage mailMsg = new MailMessage();
        mailMsg.To = "tanind@gmail.com";
        mailMsg.From = "Manage-a-company.com";
        mailMsg.Subject = "Hi! Test Mail";
        mailMsg.Body = "Hello this is a test mail" + comp_seqid.ToString();
        mailMsg.BodyFormat = MailFormat.Text;

        SmtpMail.SmtpServer = "localhost";
        SmtpMail.Send(mailMsg);
    }
}


Please help me out of this problem. I have also added ASPEMAILLib.dll and its reference in the file. Still not working.

Thanks in advance,

Indrajeet
Posted
Comments
Peter_in_2780 4-Sep-10 17:25pm    
You can improve your question by telling us what changed between when it was working and when it didn't work. Also, what happens when it doesn't work? Error messages? System error log entries? Other symptoms?
Sandeep Mewara 5-Sep-10 2:18am    
Further update by OP: Perhaps the only thing which I did was I added WinXP SP3 on my box. The code is not giving any error, nor it is making any System error log entries ... I tried putting the code in "try ... catch" block but no exception is raised. Thats the maximum I know.

I am using WS_FTP for uploading the files from my box

1 solution

It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>

If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
If needed, there are lots of article on this very site on how to send emails.
 
Share this answer
 

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


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