Welcome to ASPnix Web Hosting - Forums Sign in | Join | Help
in Search

Send email solution for ASP, .Net 1.1 and .Net 2.0

Last post 09-16-2008 4:02 PM by w3root. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 12-15-2006 6:22 PM

    • jnicolau
    • Top 150 Contributor
    • Joined on 06-06-2006
    • Posts 15
    • Points 255

    Send email solution for ASP, .Net 1.1 and .Net 2.0

    Answer

    I have copied 3 different scripts below, they are in 3 different languages which I am using in different sites hosted by ASPnix.
    None of this scripts would send emails for some days ago.
    In order to put them working I needed to change some of them, others just started working with no changes at all.

    ASP (with Persits)

     Set Mail = Server.CreateObject("Persits.MailSender")
     Mail.Username = "name@mydomain.com
     Mail.Password = "mypassword"
     Mail.Host = "mail.mydomain.com"
     Mail.From = "name@mydomain.com"
     Mail.FromName = "Questionarios Online"
     Mail.AddAddress "recipient_address", "recipient_name"
     Mail.Subject = "My Subject"
     Mail.Body = "BodyText"
     Mail.Send

    ASP .Net 1.1

    using System.Web.Mail;

    SmtpMail.SmtpServer =  "mail.mydomain.com";
    mailMsg = new MailMessage();
    mailMsg.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
    mailMsg.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "name@mydomain.com";
    mailMsg.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "mypassword";
    mailMsg.From = "name@mydomain.com";
    mailMsg.To = "recipient_address";
    mailMsg.Subject = "My Subject";
    mailMsg.Body = "Body text here";
    SmtpMail.Send(mailMsg);

    ASP .Net 2.0

    In web.config file:

     <system.net>
      <mailSettings>
       <smtp from="name@mydomain.com">
        <network host="mail.mydomain.com" userName="name@mydomain.com" password="mypassword"/>
       </smtp>
      </mailSettings>
     </system.net>

    ASP (with CDO)

    Set CdoConfiguration = CreateObject("CDO.Configuration") 
    CdoConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
    CdoConfiguration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.mydomain.com"
    CdoConfiguration.Fields.Update  
    Set Mail = Server.CreateObject("CDO.Message")
    Mail.From = EMAIL_ADDRESS_SENDER
    Mail.To = mstrEmailAddressParent
    Mail.Subject = strSubject
    Mail.HTMLBody = strBody
    Mail.Send
    set Mail = nothing
    set CdoConfiguration = nothing

    • Post Points: 65
  • 12-15-2006 10:30 PM In reply to

    • Roma
    • Top 10 Contributor
    • Joined on 06-27-2005
    • Denver, CO
    • Posts 3,665
    • Points 64,390

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    Thank you, João!

    -Roma
    ASPnix

    • Post Points: 25
  • 12-22-2006 12:02 PM In reply to

    • boddam
    • Top 75 Contributor
    • Joined on 05-24-2006
    • Posts 27
    • Points 515

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    well that's great. Except that it doesn't work for many of us. Is anyone working on this issue??
    • Post Points: 5
  • 07-26-2008 3:01 PM In reply to

    • sdtt.org
    • Not Ranked
    • Joined on 07-25-2008
    • Posts 2
    • Points 50

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    I am using asp.net 2.0 and none of these solutions work for me. So, what now? I have even tried using depricated classes.

     

    johnh

    • Post Points: 25
  • 08-06-2008 1:45 AM In reply to

    • Roma
    • Top 10 Contributor
    • Joined on 06-27-2005
    • Denver, CO
    • Posts 3,665
    • Points 64,390

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    sdtt.org:

    I am using asp.net 2.0 and none of these solutions work for me. So, what now? I have even tried using depricated classes.

    johnh

     

    What errors are you getting? I have tested those myself and it worked.

    -Roma
    ASPnix

    • Post Points: 25
  • 08-12-2008 11:37 AM In reply to

    • UberNewf
    • Not Ranked
    • Joined on 12-27-2006
    • Posts 1
    • Points 25

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    I was having this "no such user here" error message anytime I tried to send to an address that was not @MyDomain.com in my ASPX / VB .NET code. Turns out that the "smtp from" and "userName" settings I had in my WEB.CONG were for an e-mail address I had just set up as a FORWARDER in HELM - it did not actually have a mail box. The *really* werid thing was that the e-mail I sent actually went out, but I still got that "no such user here" error from my ASPX page!

    I changed the WEB.CONFIG to use the login creds of a user with a mailbox and now it works fine.

    Hope this helps. :-)

    • Post Points: 25
  • 09-11-2008 1:15 PM In reply to

    • brturner
    • Not Ranked
    • Joined on 09-11-2008
    • Posts 1
    • Points 25

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    If I put it in the web.config file, what is the code I use to actually generate and send the message?

    I am building with visual studio 2008 

     

    • Post Points: 25
  • 09-11-2008 1:24 PM In reply to

    • Roma
    • Top 10 Contributor
    • Joined on 06-27-2005
    • Denver, CO
    • Posts 3,665
    • Points 64,390

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

     I believe this is it:

     

     <system.net>
      <mailSettings>
       <smtp from="name@mydomain.com">
        <network host="mail.mydomain.com" userName="name@mydomain.com" password="mypassword"/>
       </smtp>
      </mailSettings>
     </system.net>

    -Roma
    ASPnix

    • Post Points: 5
  • 09-16-2008 4:02 PM In reply to

    • w3root
    • Not Ranked
    • Joined on 09-16-2008
    • Posts 1
    • Points 5

    Re: Send email solution for ASP, .Net 1.1 and .Net 2.0

    Asp.Net 2.0 

     

     Dim message As New System.Net.Mail.MailMessage

                    message.IsBodyHtml = True

                    message.Body = "text"

                    message.Subject = "Subject"

                    message.To.Add(New System.Net.Mail.MailAddress(Your Mail)

                    message.From = New System.Net.Mail.MailAddress(posta)

                    Dim server As New System.Net.Mail.SmtpClient(ms)

                    server.Credentials = New System.Net.NetworkCredential(Your e-mail address,Your e-mail address password)

                    server.Send(message)

     


    • Post Points: 5
Page 1 of 1 (9 items)