Results 1 to 10 of 10

Thread: send mail via asp.net

  1. #1
    keroed1 Guest

    Default send mail via asp.net

    i am trying to send a mail from an asp.net page this is what i did code wise
    Code:
    MailMessage mailMessage;
    mailMessage = new MailMessage();
    
    //set properties
    mailMessage.To = "mail1@yahoo.com";
    mailMessage.From ="mail1_Test@Keroed_corp.com";
    
    //If you want to CC this email to someone else...
    mailMessage.Cc = "mail2@hotmail.com";
    
    //If you want to BCC this email to someone else...
    mailMessage.Bcc = "mailingKE@gmail.com";
    
    //Send the email in text format
    //(to send HTML format, change MailFormat.Text to MailFormat.Html)
    mailMessage.BodyFormat = MailFormat.Text;
    
    //Set the priority - options are High, Low, and Normal
    mailMessage.Priority = MailPriority.Normal;
    
    //set subject
    mailMessage.Subject ="Test Mail";
    
    //set body
    string bodyText ="Testing send Mail" + Environment.NewLine + "Hopefull this works";
    mailMessage.Body = bodyText;
    
    //set smtp mail server
    SmtpMail.SmtpServer = "";
    
    //send mail
    SmtpMail.Send(mailMessage);
    i this works because when i go into C:\Inetpub\mailroot\Queue i see the mails that the page tried to send so i am wondering if i need to do some further configuring to my smtp server in IIS

  2. #2
    Join Date
    Dec 2004
    Posts
    1,181
    Rep Power
    0

    Default

    Yes. Did you set the relay for your IIS server? It can be configured under smtp in IIS. When it asks for the name of the computer, just use the loop back ip (127.0.0.1 - i am asuming you would want to test it from the machine you are coding on) and you should be good to. Make sure that whatever ports it uses is also free.
    'If we're supposed to work in Hex, why have we only got A fingers?'

    Follow Me: @psybuck2002us

  3. #3
    keroed1 Guest

    Default

    Quote Originally Posted by psybuck2002us View Post
    Yes. Did you set the relay for your IIS server? It can be configured under smtp in IIS. When it asks for the name of the computer, just use the loop back ip (127.0.0.1 - i am asuming you would want to test it from the machine you are coding on) and you should be good to. Make sure that whatever ports it uses is also free.
    it still failed. i dont think the port is blocked because i turned of zone alarm. do u know how to open up a port in zone alarm? i dont know other than the relay is ther anything else i should set?

  4. #4
    Join Date
    Dec 2004
    Posts
    1,181
    Rep Power
    0

    Default

    Are u behind a gateway? Like maybe at work or so? That will definitely give you problems. The best way to test this is with a computer that is directly connected to the internet.
    'If we're supposed to work in Hex, why have we only got A fingers?'

    Follow Me: @psybuck2002us

  5. #5
    keroed1 Guest

    Default

    i am using my laptop at home. i jus have my laptop and desktop plugged into the dsl. so basically via the dsl i am plugged directly to the net

  6. #6
    Join Date
    Dec 2004
    Posts
    1,181
    Rep Power
    0

    Default

    i just actually ran through the code and i realize that u hadn't set the SMTPServer.

    SmtpMail.SmtpServer = "";
    it should be SmtpMail.SmtpServer = "(local)";
    'If we're supposed to work in Hex, why have we only got A fingers?'

    Follow Me: @psybuck2002us

  7. #7
    keroed1 Guest

    Default

    Quote Originally Posted by psybuck2002us View Post
    i just actually ran through the code and i realize that u hadn't set the SMTPServer.



    it should be SmtpMail.SmtpServer = "(local)";
    that didin't work for me. but i know the code works because when i test it at work, using the my works smtp server it works fine

  8. #8
    Join Date
    Sep 2004
    Posts
    681
    Rep Power
    0

    Default

    Quote Originally Posted by keroed1 View Post
    i this works because when i go into C:\Inetpub\mailroot\Queue i see the mails that the page tried to send so i am wondering if i need to do some further configuring to my smtp server in IIS
    Well, you've established it isn't the code since the messages are making into the queue so next on the hit list is the SMTP service. Are there any SMTPSVC warnings in the Event Viewer?

  9. #9
    keroed1 Guest

    Default

    Quote Originally Posted by Goucham View Post
    Well, you've established it isn't the code since the messages are making into the queue so next on the hit list is the SMTP service. Are there any SMTPSVC warnings in the Event Viewer?
    you know say i never check, will check as i get home, i cant check here at work because more than likely my company's firewall will block that

  10. #10
    keroed1 Guest

    Default

    Quote Originally Posted by Goucham View Post
    Well, you've established it isn't the code since the messages are making into the queue so next on the hit list is the SMTP service. Are there any SMTPSVC warnings in the Event Viewer?
    jus got a chance and yes i got an error

    [Error]
    __________________________________________________ __________________________________________________ _____________________
    Message delivery to the remote domain 'yahoo.com' failed for the following reason: The remote server did not respond to a connection attempt.


    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
    __________________________________________________ __________________________________________________ ______________________

    i am wondering when i was at work the only emails i could send to where company emails. can i send to an outside mail via? smtp server?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •