Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7028461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:23:22+00:00 2026-05-28T00:23:22+00:00

This is web config <appSettings> <add key=SmtpServer value=gmail.com/> <add key=SmtpUtilisateur value=superman@gmail.com/> <add key=SmtpPassword value=12345678/>

  • 0

This is web config

 <appSettings>
     <add key="SmtpServer" value="gmail.com"/>
     <add key="SmtpUtilisateur" value="superman@gmail.com"/>
     <add key="SmtpPassword" value="12345678"/> 
 </appSettings>

This my vb method

 Sub SendSimpleMail()


    Dim Message As New Mail.MailMessage
    Dim utilisateur As String
    Dim pass As String
    Dim server As String

    utilisateur = ConfigurationSettings.AppSettings("StmpUtilisateur")
    pass = ConfigurationSettings.AppSettings("SmtpPassword")
    server = ConfigurationSettings.AppSettings("SmtpServer")

    Message.From = "superman@gmail.com"
    Message.To = "superman@gmail.com"
    Message.Subject = "test"
    Message.Body = "salut je voulais savoir comment tu allais"


    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", utilisateur)
    Message.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtppassworld", pass)
    SmtpMail.SmtpServer = server
    Try
        SmtpMail.Send(Message)
    Catch ex As Exception
        Label1.Text = ex.Message
    End Try


End Sub

I get an error like the “transport fail in connection to server”

I don’t know why this is not work well…

Thank’s for helping me!

This in vb.net

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:23:23+00:00Added an answer on May 28, 2026 at 12:23 am

    First, it is recommended to use System.Net.Mail instead of SmtpMail, since the latter has been declared obsolete by Microsoft.

    Second, the Gmail SMTP server requires a secure connection which can be set using SmtpClient.EnableSsl.

    Your example could be changed to the following:

    Sub SendSimpleMail()
    
        Dim utilisateur As String = ConfigurationSettings.AppSettings("StmpUtilisateur")
        Dim pass As String = ConfigurationSettings.AppSettings("SmtpPassword")
        Dim server As String = ConfigurationSettings.AppSettings("SmtpServer")
    
        Dim Message As New Mail.MailMessage()
        Message.From = "superman@gmail.com"
        Message.To = "superman@gmail.com"
        Message.Subject = "test"
        Message.Body = "salut je voulais savoir comment tu allais"
    
        ' You won't need the calls to Message.Fields.Add()
    
        ' Replace SmtpMail.SmtpServer = server with the following:
        Dim client As New SmtpClient(server) 
        client.Port = 587
        client.EnableSsl = true  
        client.Credentials = new System.Net.NetworkCredential(utilisateur,pass);
    
        Try
            client.Send(Message)
        Catch ex As Exception
            ' ...
        End Try
    
    End Sub
    

    If you replace the appsettings in the web.config with the following specific block, the SmtpClient will automatically configure itself accordingly:

    <system.net>
       <mailSettings>
          <smtp from="superman@gmail.com">
             <network host="smtp.gmail.com" 
                      password="12345678" 
                      userName="superman@gmail.com"
                      enableSsl="true"
                      port=587/>
          </smtp>
       </mailSettings>
    </system.net>
    

    This would reduce your method to:

    Sub SendSimpleMail()
    
        Dim Message As New Mail.MailMessage()
        Message.To = "superman@gmail.com"
        Message.Subject = "test"
        Message.Body = "salut je voulais savoir comment tu allais"
    
        Dim client As New SmtpClient() 
    
        Try
            client.Send(Message)
        Catch ex As Exception
            ' ...
        End Try
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to do something like this: <appSettings> <add key=Three value=NumberThree/> </appSettings> <appSettings configSource=One.config/>
I have the following line in my web.config <appSettings> <add key=AdminPassword value=ASDF1234 /> </appSettings>
In my Web.config file have the following setup: <add key=ClientMail value=ridermansb@bindsolution.com/> In my file
Currently my web.config has this: <appSettings> <add key=UserName /> <add key=DBServer /> <add key=DBUserName
Is Web.config's appSettings section only capable of storing simple strings like this? <appSettings> <add
How do I access a key value from web.config in my Razor view. This
I am wondering is this normal when you add this into your web.config <location
How can I have a relative path in the web.config file. This value is
How can I inject the value of an appSettings entry (from app.config or web.config)
My XML looks like this and the filename is web.config <?xml version=1.0?> <configuration> <appSettings>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.