locked
Sending Email in Silverlight RRS feed

  • Question

  •  I'm working on a new SL page to send email in Silverlight and I tried to follow the code below but I don't what IP address is referred to.  Is that the IP address from my ISP or the IP address of my internal network?

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using System.Net.Mail;
    
    namespace ContactForm.Web
    {
     [WebService(Namespace = "http://tempuri.org/")]
     [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
     [System.ComponentModel.ToolboxItem(false)]
    
     public class EmailService : System.Web.Services.WebService
     {
     [WebMethod]
     public bool SendMail(string fromAddress, string toAddress, string subject, string body)
     {
     try
     {
     MailMessage msg = new MailMessage();
     msg.From = new MailAddress(fromAddress);
     msg.To.Add(new MailAddress(toAddress));
     msg.Subject = subject;
     msg.Body = body;
     msg.IsBodyHtml = true;
    
     SmtpClient smtp = new SmtpClient("127.0.0.1"); //replace with your smtp client
     smtp.Send(msg);
     return true;
     }
     catch(Exception exp)
     {
     //log exception here..
     return false;
     }
     }
     }
    }

    Monday, September 13, 2010 5:36 PM

Answers

  • Hi,

    If mails are sent within internal network, you can set it as 192.168.1.101. Otherwise, you need to get the external IP address for your SMTP server.  And make sure Mail server is available on your server.

    Best Regards,

    Monday, September 20, 2010 1:22 AM

All replies

  • It's the address of an SMTP server that people using your website will be allowed to use. 

    Monday, September 13, 2010 7:01 PM
  • Sorry I don't get it.  Let's say in my home network, I've set a SMTP server running on Windows 2008 which IP is 192.168.1.101, my workstation's IP is 192.168.1.102 and my router's IP is 192.168.100 and 66.100.23.100 for internal and external respectively.  So which one should I use? 

    Tuesday, September 14, 2010 9:35 AM
  • Hi,

    If mails are sent within internal network, you can set it as 192.168.1.101. Otherwise, you need to get the external IP address for your SMTP server.  And make sure Mail server is available on your server.

    Best Regards,

    Monday, September 20, 2010 1:22 AM