Invio Email tramite visual basic

di il
4 risposte

Invio Email tramite visual basic

Salve a tutti..!!
Sono nuovo del forum e spero questa volta di scrivere nella sezione giusta....
Ho un problema con un semplice programma creato in visual studio 2010 e cioe':
Vorrei inviare un' email e ho trovato in giro questo codice:

Imports System.Net
Imports System.Net.Mail
Public Class Form3
Dim Mail As New MailMessage
Dim smtp As New SmtpClient("smtp.libero.it")

sub inviomail()
Mail = New MailMessage
Mail.From = New MailAddress("")
Mail.To.Add("")
Mail.Subject = ("prova email")
Mail.Body = ("messaggio")
smtp.EnableSsl = True
smtp.Port = 465
smtp.Credentials = New Net.NetworkCredential("", "miapassword")
smtp.Send(Mail)
MsgBox("INVIATA")
End sub

ma quando faccio l'invio il programma si blocca per circa un minuto e mi da' questo errore:
Immagine.png
Immagine.png

Qualcuno puo' aiutarmi..??
Ringrazio tutti in anticipo....

4 Risposte

  • Re: Invio Email tramite visual basic

    QUESTO IL DETTAGLIO DELL'ERRORE....

    System.Net.Mail.SmtpException non è stata gestita
    HResult=-2146233088
    Message=Errore durante l'invio della posta.
    Source=System
    StackTrace:
    in System.Net.Mail.SmtpClient.Send(MailMessage message)
    in PROVA.Form1.Button7_Click(Object sender, EventArgs e) in C:\Users\PC - STUDIO\Documents\Visual Studio 2010\Projects\PROVA\PROVA\Form1.vb:riga 116
    in System.Windows.Forms.Control.OnClick(EventArgs e)
    in System.Windows.Forms.Button.OnClick(EventArgs e)
    in System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    in System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
    in System.Windows.Forms.Control.WndProc(Message& m)
    in System.Windows.Forms.ButtonBase.WndProc(Message& m)
    in System.Windows.Forms.Button.WndProc(Message& m)
    in System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    in System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    in System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    in System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    in System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    in System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    in System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    in Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
    in Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
    in Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
    in PROVA.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:riga 81
    in System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    in System.AppDomain.nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    in System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
    in System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
    in System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
    in System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
    in System.Activator.CreateInstance(ActivationContext activationContext)
    in Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
    in System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    in System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    in System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    in System.Threading.ThreadHelper.ThreadStart()
    InnerException: System.IO.IOException
    HResult=-2146232800
    Message=Impossibile leggere dati dalla connessione del trasporto: Connessione in corso interrotta forzatamente dall'host remoto.
    Source=System
    StackTrace:
    in System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    in System.Net.DelegatedStream.Read(Byte[] buffer, Int32 offset, Int32 count)
    in System.Net.BufferedReadStream.Read(Byte[] buffer, Int32 offset, Int32 count)
    in System.Net.Mail.SmtpReplyReaderFactory.ReadLines(SmtpReplyReader caller, Boolean oneLine)
    in System.Net.Mail.SmtpReplyReaderFactory.ReadLine(SmtpReplyReader caller)
    in System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint)
    in System.Net.Mail.SmtpTransport.GetConnection(ServicePoint servicePoint)
    in System.Net.Mail.SmtpClient.GetConnection()
    in System.Net.Mail.SmtpClient.Send(MailMessage message)
    InnerException: System.Net.Sockets.SocketException
    ErrorCode=10054
    HResult=-2147467259
    Message=Connessione in corso interrotta forzatamente dall'host remoto
    NativeErrorCode=10054
    Source=System
    StackTrace:
    in System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
    in System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    InnerException:
  • Re: Invio Email tramite visual basic

    Usa la porta 587 al posto della 465
  • Re: Invio Email tramite visual basic

    SEI UN GRANDE..!!
    Era due giorni che provavo....
    adesso con la porta 587 sembra che funziona alla grande....
    GRAZIE DAVVERO..!!
  • Re: Invio Email tramite visual basic

    Scusate se approfitto....
    nel caso volessi inviare da ..??
    N.B. si tratta di un dominio aruba
Devi accedere o registrarti per scrivere nel forum
4 risposte