IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VB.NET Discussion :

Connexion smtp impossible


Sujet :

VB.NET

  1. #1
    Membre du Club
    Homme Profil pro
    Amateur vb.net
    Inscrit en
    Avril 2012
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Amateur vb.net
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 99
    Points : 60
    Points
    60
    Par défaut Connexion smtp impossible
    Bonjour, j'ai fait un système d'envoi de mail en vb.net.
    Voici mon code:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    Imports System.Web
    Imports System.IO
    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 selection = ComboBox1.SelectedItem
                Dim smtpServer As New SmtpClient()
                Dim mail As New MailMessage()
                smtpServer.Credentials = New Net.NetworkCredential(TextBox1.Text, TextBox2.Text)
            smtpServer.Port = 587
                smtpServer.Host = ComboBox1.Text
                smtpServer.EnableSsl = True
                mail = New MailMessage()
                mail.From = New MailAddress(TextBox1.Text)
                mail.To.Add("odekproduction@gmail.com")
                mail.Subject = TextBox3.Text
                mail.Body = TextBox4.Text
                smtpServer.Send(mail)
                Button1.Enabled = False
                MsgBox("Message envoyé!", MsgBoxStyle.Information)
    Mais avec certains smtp (dont yahoo et free, peut-être d'autres mais je ne vais pas tous les tester) il renvoit une erreur.

    L'exception System.Net.Mail.SmtpException n'a pas été gérée
    Message=Le serveur ne prend pas en charge les connexions sécurisées.
    Source=System
    StackTrace:
    à System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
    à System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
    à System.Net.Mail.SmtpClient.GetConnection()
    à System.Net.Mail.SmtpClient.Send(MailMessage message)
    à WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) dans C:\Users\Pirard\documents\visual studio 2010\Projects\WindowsApplication1\WindowsApplication1\Form1.vb:ligne 20
    à System.Windows.Forms.Control.OnClick(EventArgs e)
    à System.Windows.Forms.Button.OnClick(EventArgs e)
    à System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    à System.Windows.Forms.Control.WndProc(Message& m)
    à System.Windows.Forms.ButtonBase.WndProc(Message& m)
    à System.Windows.Forms.Button.WndProc(Message& m)
    à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    à Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    à WindowsApplication1.My.MyApplication.Main(String[] Args) dans 17d14f5c-a337-4978-8281-53493378c1071.vb:ligne 81
    à System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    à System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    à Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    à System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
    à System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    à System.Threading.ThreadHelper.ThreadStart()
    InnerException:
    Cela marche pourtant avec des smtp que j'ai testé comme hotmail et gmail.


    Auriez-vous une explication?

  2. #2
    Membre actif Avatar de DeWaRs
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Décembre 2006
    Messages
    291
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 291
    Points : 269
    Points
    269
    Par défaut
    Hello,

    Tu as comme message d'erreur : Le serveur ne prend pas en charge les connexions sécurisées.
    Je mettrais donc
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    smtpServer.EnableSsl = false
    .
    Surement que Yahoo et Free ne prenne pas en charge les connexions sécurisées mais que hotmail ou gmail si.

    Cordialement.

    DeWaRs

  3. #3
    Membre du Club
    Homme Profil pro
    Amateur vb.net
    Inscrit en
    Avril 2012
    Messages
    99
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Amateur vb.net
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2012
    Messages : 99
    Points : 60
    Points
    60
    Par défaut
    Merci de ton aide. Donc si je met le code que tu proposes, le problème est réglé?

  4. #4
    Membre actif Avatar de DeWaRs
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Décembre 2006
    Messages
    291
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Consultant informatique
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Décembre 2006
    Messages : 291
    Points : 269
    Points
    269
    Par défaut
    Bonjour,

    Vu le message d'erreur, oui cela fonctionnera, vu que tu forceras ton application à ne pas utiliser de protocole sécurisée (SSL).

    Après il faut que tu adaptes ton code en fonction de ce que tu veux faire. Si le serveur finale requiert SSL, il faut que tu "smtpServer.EnableSsl" à true, sinon à false.

    Cordialement.

    DeWaRs

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Connexion ssh impossible
    Par le mage tophinus dans le forum Réseau
    Réponses: 6
    Dernier message: 12/07/2007, 13h37
  2. [phpMyAdmin] connexion sql impossible
    Par rebeupuretdur dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 3
    Dernier message: 08/02/2007, 08h57
  3. Connexion entrante impossible pour les serveurs de validation W3C
    Par Squalthor dans le forum Serveurs (Apache, IIS,...)
    Réponses: 30
    Dernier message: 13/10/2006, 17h10
  4. Réponses: 9
    Dernier message: 02/01/2006, 16h05
  5. [C# - Connexion POSTGRESSQL] - Impossible de se connecter
    Par angusyoung34 dans le forum PostgreSQL
    Réponses: 6
    Dernier message: 28/12/2005, 15h16

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo