Smtp

tetra

Member
Joined
Jan 11, 2008
Messages
12
Programming Experience
3-5
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")

'set the content
mail.Subject = "This is an email"
mail.Body = "this is a sample body"

'send the message
Dim smtp As New SmtpClient("127.0.0.1")
smtp.Send(mail)

This is the example of code I want to try using to send a basic email. The only problem I have is what do I put at the SMTPClient instead of the home address of 127.0.0.1

I'm sending a basic email from one hotmail account to another, any tips?

Thanks!
 
I believe that where you're putting your home IP, you'll need to put the address of the POP3 server. I've never used System.Net.Mail for anything other than the Exchange server in my building, but I believe that I read somewhere you'll use the POP3 address. Or at least the .NET equivalent of the POP3 address.
 
So i would need to put the POP3 address of hotmail? Also, how would this work without specifying the username and password to be able to send an email from an account?
 
I believe you would need the POP3 address. If someone knows otherwise please correct me.

And it probably won't work without specifying an address and password. You'll need to use credentials, like this:

VB.NET:
 Sub Authenticate()
'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")

'set the content
mail.Subject = "This is an email"
mail.Body = "this is the body content of the email."

'send the message
Dim smtp As New SmtpClient("127.0.0.1")

'to authenticate we set the username and password properites on the SmtpClient
[B][COLOR="Red"]smtp.Credentials = New NetworkCredential("username", "secret")[/COLOR][/B]
smtp.Send(mail)
End Sub 'Authenticate

For any questions on sending mail through .NET, check out this site.


As I've said before, i've never tried to use this outside of my local exchange server, so i'm not sure how well this will work, but this is how I would try it.
 
Supposably the POP3 address for hotmail is pop3hot.com I added this, as well as the credentials but still no luck.
 
POP3 is for receive, SMTP is for send. You have to use the address of SMTP server to send mail. When you sign up for internet access your ISP give you this info.
 
OK, that makes sense, I got my ISP's SMTP server address.

mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("you@yourcompany.com")

the mail.From, I should put my ISP email address and not a hotmail address correct? Because if I put a hotmail address in the From, don't I need a login and password?
 
I tested my ISP's SMTP server with telnet and I can connect fine, don't need a user name and password.

But I'm getting an exception that says "Failure sending mail" on the last line of the program which is: smtp.Send(mail)

EDIT: I got it working, everything is fine. Now I'm trying to get it to my cell phone, since my provider states you can do it by changing the receiving address to:

10digitnumber@pcs.rogers.com

Tried this, but it won't appear on my cell phone
 
Last edited:
Back
Top