Visual Basic.NET - Programa para enviar correo.

 
Vista:
sin imagen de perfil
Val: 344
Bronce
Ha mantenido su posición en Visual Basic.NET (en relación al último mes)
Gráfica de Visual Basic.NET

Programa para enviar correo.

Publicado por Miguel (281 intervenciones) el 26/04/2016 19:57:54
Tengo este programa que cuando lo utilice con Windows XP y Visual Basic 6.0 funcionaba correctamente pero ahora que le quiero utilizar en un programa con Visual Studio 2015 y con Windows 10 da un error. Aquí pongo el código haber si alguna persona puede decirme donde tengo que actualizar código.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Private Sub messageSenderCode()
	Try
		Dim smtpServer As New SmtpClient()
		Dim mail As New MailMessage()
		'Username & Password to connect to the sending account (Gmail account)
		smtpServer.Credentials = New Net.NetworkCredential(txtUsername.Text, txtPassword.Text)
		'Using Gmail (settin all the details required)
		smtpServer.Port = 587           'the gmail's port number
		smtpServer.Host = "smtp.gmail.com" 'Gmail Smtp server 
		smtpServer.EnableSsl = True        'SSL Checker setn to true
		mail = New MailMessage()
		mail.From = New MailAddress(txtUsername.Text)
		mail.To.Add(txtEmail.Text)
		mail.Subject = txtSubject.Text  'setting the message subject
		mail.Body = txtMessage.Text     'etting the body of the message
		smtpServer.Send(mail)
		MsgBox("Mail Sent to" & "--" & txtEmail.Text, ) 'this confirms that the message has been sent successfully
	Catch ex As Exception
		MsgBox(ex.Message) ' this code will throw an error if the code does not run successfully
	End Try
End Sub

Gracias y un saludo
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder