I have been trying to make my own app for sending emails. But I have been trying to make it where I don't have to sign into my hotmail account, it just does it automatically. Then all I need to do is fill out the recipients, subject, and body for the message and hit send but I am having issues. I can't for the life of me get it to work. After a week of messing around with it and scouring the internet for help, I have gotten to where the only error I get is, failure to send message.
Please, I need some help and am getting frustrated with this.
I have been working on this because I can't use Outlook with hotmail and I figured it would be interesting to try, but it turns out to be a lot harder than I expected. Any help would be appreciated, but all I have been getting on other forums is just links to other topics and they are all different so that have just confused me more. If someone could look at my code and just point me in the right direction, I would love it.
Thanks for any help I receive.
VB.NET:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Message As MailMessage = New MailMessage()
Dim Smtp As New SmtpClient()
Dim SmtpUser As New System.Net.NetworkCredential()
'-- Build Message
Message.From = New MailAddress("myemail@hotmail.com", "SMTP.live.com")
Message.To.Add(New MailAddress("recipientsemails@_____.com"))
Message.IsBodyHtml = False
Message.Subject = "textbox1.text"
Message.Body = "textbox2.text"
'-- Define Authenticated User
SmtpUser.UserName = "myusername"
SmtpUser.Password = "mypassword"
SmtpUser.Domain = "@hotmail.com"
'-- Send Message
Smtp.UseDefaultCredentials = False
Smtp.Credentials = SmtpUser
Smtp.Host = "SMTP.live.com"
Smtp.DeliveryMethod = SmtpDeliveryMethod.Network
Smtp.Send(Message)
MessageBox.Show("Message Sent.", "Congratulations", _
MessageBoxButtons.OK, MessageBoxIcon.Information)
Me.Close()
End Sub
End Class
Please, I need some help and am getting frustrated with this.
I have been working on this because I can't use Outlook with hotmail and I figured it would be interesting to try, but it turns out to be a lot harder than I expected. Any help would be appreciated, but all I have been getting on other forums is just links to other topics and they are all different so that have just confused me more. If someone could look at my code and just point me in the right direction, I would love it.
Thanks for any help I receive.