Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all ,

I am trying to send email using gmail.I am specifying the host and every thing but it is giving me this error : The smtp host is not specified.

Here is my code :

VB
Dim smtp As New SmtpClient("smtp.gmail.com", 587)


          smtp.DeliveryMethod = SmtpDeliveryMethod.Network
          smtp.EnableSsl = True

          smtp.UseDefaultCredentials = False
          Dim SMTPUserInfo As New System.Net.NetworkCredential("myemail", "pass")
          smtp.Credentials = SMTPUserInfo

          e.Message.From = New MailAddress("myemail@gmail.com")
          e.Message.IsBodyHtml = True
          e.Message.Subject = "Allo Magazine : Registration Confirmation Email"
          e.Message.Body = e.Message.Body.Replace("<%AC%>", userId.ToString())
          smtp.Send(e.Message)


So please can anyone tell me what is the error ?

Thanks in advance.

[Edit]
XML
<maildefinition priority="High" from="ahmad.hjaj@gmail.com" bodyfilename="~/ConfirmationEmailHTML/ConfirmationEmail.htm">
                  </maildefinition>
Posted
Updated 31-Aug-11 23:24pm
v2

1 solution

The first thing that springs to mind is you haven't specified the To address for the message.

Other than that it looks ok.
 
Share this answer
 
Comments
mhamad zarif 1-Sep-11 3:50am    
This code is inside sending email event for create user wizard.So the email address to is specified automatically.Isn't it ? please help me.I have been facing this problem since 3 days.And i am not able to finish my website due to this error.
OriginalGriff 1-Sep-11 3:55am    
No. You have to tell each individual message who it is to go to...
Think about it: you might want to email the user, you might want to email the admin that a new user has been registered!
mhamad zarif 1-Sep-11 4:48am    
The email is being received.But always this error is showing.
OriginalGriff 1-Sep-11 4:50am    
Exactly which line is showing the error?
Can you copy the exception detail?
mhamad zarif 1-Sep-11 4:52am    
there is no exceptions generated.I debugged the code 10's of times.But i have this in the create user wizard,so is it causing the problem :
please look down:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900