fizzer666
asked on
passwordRecovery control sending email via gmail account problem
I have a PasswordRecovery control and I want to use my own personal gmail account to test that the emails are being sent out.
I've managed to send out a mail using the following code:
'Build the message
Dim msg As New System.Net.Mail.MailMessag e()
msg.To.Add("Destination email address goes here")
msg.From = New MailAddress("myEmailAddres s@gmail.co m", "Mark", System.Text.Encoding.UTF8)
msg.Subject = "Test mail using .net2.0"
msg.SubjectEncoding = System.Text.Encoding.UTF8
msg.Body = "This is my msg Body"
msg.BodyEncoding = System.Text.Encoding.UTF8
msg.IsBodyHtml = False
msg.Priority = MailPriority.High
'Add the Creddentials
Dim Client As New SmtpClient
Client.Credentials = New System.Net.NetworkCredenti al("myEmai lAddress@g mail.com", "mypassword")
Client.Port = 587
Client.Host = "smtp.gmail.com"
Client.EnableSsl = True
'Client.SendCompleted += New SendCompletedEventHandler( client_Sen dCompleted )
' object userState=msg;
Try
Client.Send(msg)
Catch ex As Exception
End Try
I've taken out my email address in the above but it works fine. The problem is how do I put these settings in the config file rather than in code. I've used the following:
<system.net>
<mailSettings>
<smtp from="myemail@gmail.com">
<network host="smtp.gmail.com" password="myPassword" port="587"
userName="myemail@gmail.co m" />
</smtp>
</mailSettings>
</system.net>
Again, i've removed my email and password and the username and password are correct but the above doesn't work with the PasswordRecovery control. I think its because I need to enable SSL but how do i do this in the config file?
I've managed to send out a mail using the following code:
'Build the message
Dim msg As New System.Net.Mail.MailMessag
msg.To.Add("Destination email address goes here")
msg.From = New MailAddress("myEmailAddres
msg.Subject = "Test mail using .net2.0"
msg.SubjectEncoding = System.Text.Encoding.UTF8
msg.Body = "This is my msg Body"
msg.BodyEncoding = System.Text.Encoding.UTF8
msg.IsBodyHtml = False
msg.Priority = MailPriority.High
'Add the Creddentials
Dim Client As New SmtpClient
Client.Credentials = New System.Net.NetworkCredenti
Client.Port = 587
Client.Host = "smtp.gmail.com"
Client.EnableSsl = True
'Client.SendCompleted += New SendCompletedEventHandler(
' object userState=msg;
Try
Client.Send(msg)
Catch ex As Exception
End Try
I've taken out my email address in the above but it works fine. The problem is how do I put these settings in the config file rather than in code. I've used the following:
<system.net>
<mailSettings>
<smtp from="myemail@gmail.com">
<network host="smtp.gmail.com" password="myPassword" port="587"
userName="myemail@gmail.co
</smtp>
</mailSettings>
</system.net>
Again, i've removed my email and password and the username and password are correct but the above doesn't work with the PasswordRecovery control. I think its because I need to enable SSL but how do i do this in the config file?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER