C# .Net Sending an e-mail to an application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jive
    New Member
    • Aug 2008
    • 5

    C# .Net Sending an e-mail to an application

    Pls help, i am making an c# .net application that will always be running on a computer and i want it to write the subject (of the e-mail i recieved on my e-mail server) in the applications text box called textbox1 (textbox1.Text = "?????").
    A code sample would be of great help...
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Do you have a method for retreiving the email header?
    There are .NET methods for accessing information from Microsoft Exchange server, but .NET does not have anything built-in regarding POP3 or IMAP for accessing emails that I am aware of.

    Comment

    • jive
      New Member
      • Aug 2008
      • 5

      #3
      Originally posted by Plater
      Do have a method for retreiving the email header?
      There are .NET methods for accessing information from Microsoft Exchange server, but .NET does not ahve anything regarding POP3 or IMAP for accessing emails that I am aware of.
      Thx for helping...
      I found the EAGetMail.dll to help me solve this problem and it worked...

      Comment

      • divyavk21
        New Member
        • Sep 2008
        • 6

        #4
        Can you please provide me a sample code how to send Emails from C#.

        Thanks.
        Dijo.

        Comment

        • jay123
          New Member
          • Sep 2008
          • 121

          #5
          header file u need to add
          using System.Net.Mail ;


          coding
          Code:
          MailMessage Mail1 = new MailMessage();
                          MailAddress ma1 = new MailAddress(Emailfrom.Text);
                          Mail1.From = ma1;
                          Mail1.To.Add(emailto.Text);// reciever email id
                          Mail1.CC.Add(Emailfrom.Text);// textbox from where sender email is to be retrieved
                          Mail1.Subject = subject.Text;// subject textbox
                          Mail1.IsBodyHtml = true;
                          string msg = meassage.Text;// textbox in which nessage is written
                          
                          Mail1.Body = msg;
          
                          try
                          {
                              SmtpClient smtpMailObj = new SmtpClient();
                              smtpMailObj.Host = "xxx.xxx.xxx.xxx";// server ip address
                              smtpMailObj.Send(Mail1);
                              //  Response.Write("Your Message has been sent successfully");
                              Label4.Text = "Your Message has been sent successfully";//label showing that message has been sent
                          }
          
                          catch (Exception)
                          {
                              //Response.Write("Message Delivery Fails");
                              Label4.Text = "Message Delivery Fails";
                          }
          Last edited by Curtis Rutland; Sep 4 '08, 01:30 PM. Reason: Added Code Tags - Please use the # button

          Comment

          • Curtis Rutland
            Recognized Expert Specialist
            • Apr 2008
            • 3264

            #6
            First of all, please use [CODE] tags when you post code.

            Second, please do not "hijack" other threads. Unless your issue is exactly the same as the original poster's issue, please start your own thread.

            MODERATOR

            Comment

            • jay123
              New Member
              • Sep 2008
              • 121

              #7
              Originally posted by insertAlias
              First of all, please use [CODE] tags when you post code.

              Second, please do not "hijack" other threads. Unless your issue is exactly the same as the original poster's issue, please start your own thread.

              MODERATOR
              sorry sir,
              i m new to this developer form, so didnt know much of the rule that should be followed..

              Comment

              • Curtis Rutland
                Recognized Expert Specialist
                • Apr 2008
                • 3264

                #8
                Originally posted by jay123
                sorry sir,
                i m new to this developer form, so didnt know much of the rule that should be followed..
                That's understandable.

                Please read our posting guidelines for the rules:

                Comment

                • divyavk21
                  New Member
                  • Sep 2008
                  • 6

                  #9
                  Thanks for providing me the coding, i'll work on it and let you know the status. by monday.

                  Thanks a lot.
                  Have a great weekend.

                  Comment

                  Working...