sending emails

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Ria12
    New Member
    • Feb 2009
    • 26

    sending emails

    Hi, I am having a gridview which contains a hyperlink template field which is bound to show the email address of the employees.Now when i click the hyperlink feild in the gridview i want to send an email to the selected employee.
    I am new to asp.net....Plz if anyone can tell me how this could be done......
    Thnks .
  • alamodgal
    New Member
    • Dec 2008
    • 38

    #2
    hiiiiii
    use this :
    Dim objMail As System.Web.Mail .MailMessage = New System.Web.Mail .MailMessage


    objMail.To = "bhupinder@owt. cc"

    objMail.From = "shikha@owt .cc"
    objMail.Subject = "hi"

    objMail.Body = "fdbsfdsfv"
    objMail.BodyFor mat = MailFormat.Html
    SmtpMail.SmtpSe rver = ConfigurationMa nager.AppSettin gs("SMTP")

    SmtpMail.Send(o bjMail)




    And also add a key named "SMTP" in your web config and give it value of your server e.g.

    <add key="SMTP" value="192.168. 0"/>

    Comment

    • Ria12
      New Member
      • Feb 2009
      • 26

      #3
      I m working in C#.Code is almost the same,but with this code Mail is being sent but it's not being received ...can u Plz Check the Code...

      using System.Net.Mail ;

      MailMessage msg = new MailMessage(txt From.Text, txtTo.Text, txtsub.Text, txtMsg.Text);
      SmtpClient mySmtp = new SmtpClient("loc alhost");
      try
      {
      mySmtp.Send(msg );

      Response.Write( "Mail Sent");
      }
      catch (Exception ex)
      {
      Response.Write( ex);
      }.

      plz help me. I need it urgently.
      thanks

      Comment

      • alamodgal
        New Member
        • Dec 2008
        • 38

        #4
        hiiiiiii
        Use mail message like this:
        MailMessage msg = new MailMessage();
        msg .To = txtTo.Text;
        msg .From =txtFrom.Text;
        msg .Subject =txtsub.Text;
        msg .Body = txtMsg.Text;
        msg .BodyFormat = System.Web.Mail .MailFormat.Htm l;

        Comment

        • Ria12
          New Member
          • Feb 2009
          • 26

          #5
          There are many Errors like Web.Mail is obsolete....Plz can u Explain me what i have to use to send mail in asp.net C#...

          Comment

          • alamodgal
            New Member
            • Dec 2008
            • 38

            #6
            MailMessage msg = new MailMessage();
            msg .To = txtTo.Text;
            msg .From =txtFrom.Text;
            msg .Subject =txtsub.Text;
            msg .Body = txtMsg.Text;

            SmtpMail.SmtpSe rver = ConfigurationSe ttings.AppSetti ngs["SMTP"].ToString();
            SmtpMail.Send(m sg);


            Add SMTP key in your web config like this in <appsettings> tag
            <appsettings>
            <add key="SMTP" value="localhos t"/>
            </appsettings>

            And add
            using System.Web.Mail instead of using System.Net.Mail ;

            Comment

            • Ria12
              New Member
              • Feb 2009
              • 26

              #7
              Hi......Thks for yur help.
              Its not showing any errors now, but the email is not being recieved.
              I dont know where i m going wrong ...Are there any other settings which i have to make. For eg.When i send the email from xyz@gmail.com to abc@gmail.com the email is not recieved.
              Thanks ......again.

              Comment

              • alamodgal
                New Member
                • Dec 2008
                • 38

                #8
                You cannot send mail from localhost smtp server to online mail ids like yahoo, gmail....... For this you have to change your smtp value from localhost to your online server value

                Comment

                • Ria12
                  New Member
                  • Feb 2009
                  • 26

                  #9
                  I have tried alot,my mail's r in Drop folder of mailroot when i send to localhost ...but when try to send on yahoo or gmail...they r in Bad folder...can u plz guide me what settings i have to do it in asp.net 2.0?

                  Comment

                  • bhupinder
                    New Member
                    • Feb 2009
                    • 32

                    #10
                    Originally posted by Ria12
                    I have tried alot,my mail's r in Drop folder of mailroot when i send to localhost ...but when try to send on yahoo or gmail...they r in Bad folder...can u plz guide me what settings i have to do it in asp.net 2.0?
                    Hiiiiiiiiiiiiii Ria12
                    You cant send yahoo or gmail in ur local host. bec. this is live server. u have only local server.

                    Comment

                    Working...