Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. MailMessage [modified]

MailMessage [modified]

Scheduled Pinned Locked Moved ASP.NET
csharphtmlhelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Assaf82
    wrote on last edited by
    #1

    Hello I try to send a mailmessage to this mail info@ihacademy.net i did a form where i specify all the constant of the mail and this is the code behinder. "protected void Send_Email(Object Sender, EventArgs e) { System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = Request.Form["to"]; mail.From = Request.Form["from"]; if (Request.Form["format"].Equals("text")) mail.BodyFormat = MailFormat.Text; else mail.BodyFormat = MailFormat.Html; mail.Subject = Request.Form["subject"]; mail.Body = Request.Form["body"]; SmtpMail.Send(mail); Response.Flush(); Message.Text = "Message Sent...

    " + "[Go Back]()"; }" I don't have an error but nothing happen and i don't receive any message in the mail. Any advice or correction will be greatly appreciated And thanks in advance Assaf modified on Tuesday, June 3, 2008 12:30 PM

    S G 2 Replies Last reply
    0
    • A Assaf82

      Hello I try to send a mailmessage to this mail info@ihacademy.net i did a form where i specify all the constant of the mail and this is the code behinder. "protected void Send_Email(Object Sender, EventArgs e) { System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = Request.Form["to"]; mail.From = Request.Form["from"]; if (Request.Form["format"].Equals("text")) mail.BodyFormat = MailFormat.Text; else mail.BodyFormat = MailFormat.Html; mail.Subject = Request.Form["subject"]; mail.Body = Request.Form["body"]; SmtpMail.Send(mail); Response.Flush(); Message.Text = "Message Sent...

      " + "[Go Back]()"; }" I don't have an error but nothing happen and i don't receive any message in the mail. Any advice or correction will be greatly appreciated And thanks in advance Assaf modified on Tuesday, June 3, 2008 12:30 PM

      S Offline
      S Offline
      SomeGuyThatIsMe
      wrote on last edited by
      #2

      If you are using .NET 2.0 you should use System.Net.Mail, but you never set the smtp server you were using, so the code had no idea where to send the message. SmtpMail.Servers.Add is close to what you need. I recomend System.Net.Mail it lets you create a smtp object and control things that way, but if you arent using .NET 2 you wont have it, we had problems with the SmtpMail class in .NET 1.1, sometimes it threw an exception about the server so we had to readd the server using a different method and then it would work.

      A W 2 Replies Last reply
      0
      • A Assaf82

        Hello I try to send a mailmessage to this mail info@ihacademy.net i did a form where i specify all the constant of the mail and this is the code behinder. "protected void Send_Email(Object Sender, EventArgs e) { System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage(); mail.To = Request.Form["to"]; mail.From = Request.Form["from"]; if (Request.Form["format"].Equals("text")) mail.BodyFormat = MailFormat.Text; else mail.BodyFormat = MailFormat.Html; mail.Subject = Request.Form["subject"]; mail.Body = Request.Form["body"]; SmtpMail.Send(mail); Response.Flush(); Message.Text = "Message Sent...

        " + "[Go Back]()"; }" I don't have an error but nothing happen and i don't receive any message in the mail. Any advice or correction will be greatly appreciated And thanks in advance Assaf modified on Tuesday, June 3, 2008 12:30 PM

        G Offline
        G Offline
        Gayani Devapriya
        wrote on last edited by
        #3

        Hi, I thnk what is missing is SmtpMail.SmtpServer = "192.167.0.25";, which you need to asssing before calling the Send method. Simple Mail Transfer Protocol (SMTP) server for delivery from a .NET Framework application. Thx, Gayani

        1 Reply Last reply
        0
        • S SomeGuyThatIsMe

          If you are using .NET 2.0 you should use System.Net.Mail, but you never set the smtp server you were using, so the code had no idea where to send the message. SmtpMail.Servers.Add is close to what you need. I recomend System.Net.Mail it lets you create a smtp object and control things that way, but if you arent using .NET 2 you wont have it, we had problems with the SmtpMail class in .NET 1.1, sometimes it threw an exception about the server so we had to readd the server using a different method and then it would work.

          A Offline
          A Offline
          Assaf82
          wrote on last edited by
          #4

          Thanks I use System.Net.Mail but it give many error on it i'll give my code "System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); /* Step 2*/ message.To.Add("info@ihacademy.net"); message.From.Address = "assaf-hassan@hotmail.com"; message.Subject = "Email Subject"; /*Step 3*/ message.IsBodyHtml.Equals(true); //message.BodyFormat = MailFormat.Html; /*Step 4*/ message.Body = "this a test for the mailmessage"; /*Step 5*/ SmtpMail.Send(message); Response.Write("Email Sent");" the two error is: 1-Error1 Property or indexer 'System.Net.Mail.MailAddress.Address' cannot be assigned to -- it is read only 2-Error2 The name 'SmtpMail' does not exist in the current context So any help i'll appreciated Thanks in advance

          Assaf

          S 1 Reply Last reply
          0
          • A Assaf82

            Thanks I use System.Net.Mail but it give many error on it i'll give my code "System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); /* Step 2*/ message.To.Add("info@ihacademy.net"); message.From.Address = "assaf-hassan@hotmail.com"; message.Subject = "Email Subject"; /*Step 3*/ message.IsBodyHtml.Equals(true); //message.BodyFormat = MailFormat.Html; /*Step 4*/ message.Body = "this a test for the mailmessage"; /*Step 5*/ SmtpMail.Send(message); Response.Write("Email Sent");" the two error is: 1-Error1 Property or indexer 'System.Net.Mail.MailAddress.Address' cannot be assigned to -- it is read only 2-Error2 The name 'SmtpMail' does not exist in the current context So any help i'll appreciated Thanks in advance

            Assaf

            S Offline
            S Offline
            SomeGuyThatIsMe
            wrote on last edited by
            #5

            a search of msdn will reveal that the to and from address should be set in the constructor of the MailMessage object, and that SmtpMail is obsolete(complier warnings should tell you this if you read them) and that you have to create an SmtpClient object and use it instead of SmtpMail. the context help in VS should have lead you down that path as well. Sorry if i seem rude I dont mind helping but quite a few of the posts to these forums are of the "pls urgent send code" or from people who never look at the help or google searches and that gets old fast, combinded with a horrid day at work puts me in a not very good mood. I dont know what your complier warnings are set to but i recomend level 4 as it will usually give you some decent information.

            1 Reply Last reply
            0
            • S SomeGuyThatIsMe

              If you are using .NET 2.0 you should use System.Net.Mail, but you never set the smtp server you were using, so the code had no idea where to send the message. SmtpMail.Servers.Add is close to what you need. I recomend System.Net.Mail it lets you create a smtp object and control things that way, but if you arent using .NET 2 you wont have it, we had problems with the SmtpMail class in .NET 1.1, sometimes it threw an exception about the server so we had to readd the server using a different method and then it would work.

              W Offline
              W Offline
              w209
              wrote on last edited by
              #6

              :) Hello Frnd do you want ur application to send mail? if yes then u need SMTP Service on ur Pc which is provided by the iis you sould use these namespaces using System.Web.Security; using System.Net.Mail; using System.Net.Mime; and then you should create a object of System.Net.Mail.MailMessage this will provide you all the function of the Mail MEssage and you have to use SmtpClient objName=new SmtpClient(); client.Credentials = new System.Net.NetworkCredential("your emailAddress", "your Passowrd"); client.Host = "host name "; client.Port = port on which number; client.EnableSsl = true; should try this in youor code.. Do let me know if u have any problem or not

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups