Problem beim Versenden von E-Mail

  • VB.NET

Es gibt 8 Antworten in diesem Thema. Der letzte Beitrag () ist von exotobias1.

    Problem beim Versenden von E-Mail

    Hallo,
    tut mir leid, dass ich schon wieder einen Theard aufmachen muss, aber ich hab schon tausende Codes versucht und keiner scheint zu passen,
    obwohl andere User über das selbe Codefragment gejubelt haben. (Wurmsatz :whistling: )
    Ich weiß echt nicht was ich falsch mache, und ob es überhaupt an meinem Code liegt.

    (Bisheriger) Code:

    VB.NET-Quellcode

    1. Me.UseWaitCursor = True
    2. Dim senderofmail As New Mail.SmtpClient("smtp.live.com")
    3. senderofmail.UseDefaultCredentials = False
    4. senderofmail.Credentials = New NetworkCredential("nichtgesagt@hotmail.de", "nichtgesagt")
    5. senderofmail.EnableSsl = True
    6. senderofmail.Port = 25
    7. 'Senden
    8. senderofmail.Send("nichtgesagt@hotmail.de", "nichtgesagt@hotmail.de", "Betreff", "Body")
    9. LinkLabel16.Enabled = False
    10. Me.UseWaitCursor = False

    Was mach ich falsch?

    Exeption:
    TimeOut überschritten
    Spoiler anzeigen

    Quellcode

    1. System.Net.Mail.SmtpException wurde nicht behandelt.
    2. Message="Fehler beim Senden von Mail."
    3. Source="System"
    4. StackTrace:
    5. bei System.Net.Mail.SmtpClient.Send(MailMessage message) bei System.Net.Mail.SmtpClient.Send(String from, String recipients, String subject, String body) bei Projekt.MainWindow.LinkLabel16_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) in C:\Users\Username\Documents\Visual Studio 2008\Projects\Projekt\Projekt\MainWindow.vb:Zeile 1368. bei System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e) bei System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs e) bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.Label.WndProc(Message& m) bei System.Windows.Forms.LinkLabel.WndProc(Message& msg) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) bei System.Windows.Forms.Application.Run(ApplicationContext context) bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel() bei Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine) bei Projekt.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:Zeile 81. bei System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() bei System.Threading.ThreadHelper.ThreadStart_Context(Object state) bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) bei System.Threading.ThreadHelper.ThreadStart()
    6. InnerException: System.Net.WebException
    7. Message="Die Verbindung mit dem Remoteserver kann nicht hergestellt werden."
    8. Source="System"
    9. StackTrace:
    10. bei System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout) bei System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback) bei System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback) bei System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) bei System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) bei System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) bei System.Net.Mail.SmtpClient.GetConnection() bei System.Net.Mail.SmtpClient.Send(MailMessage message)
    11. InnerException: System.Net.Sockets.SocketException
    12. ErrorCode=10060
    13. Message="Ein Verbindungsversuch ist fehlgeschlagen, da die Gegenstelle nach einer bestimmten Zeitspanne nicht richtig reagiert hat, oder die hergestellte Verbindung war fehlerhaft, da der verbundene Host nicht reagiert hat 65.55.172.254:25"
    14. NativeErrorCode=10060
    15. Source="System"
    16. StackTrace:
    17. bei System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) bei System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP) bei System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
    18. InnerException:


    ?(

    *Topic verschoben*

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „Marcus Gräfe“ ()

    Probiers mal mit:

    VB.NET-Quellcode

    1. Dim Msg As New Net.Mail.MailMessage
    2. Dim myCredentials As New System.Net.NetworkCredential
    3. myCredentials.UserName = "E-MAiladresse"
    4. myCredentials.Password = "Passwort"
    5. Msg.IsBodyHtml = False
    6. Dim mySmtpsvr As New Net.Mail.SmtpClient()
    7. mySmtpsvr.Host = "smtp.host.de"
    8. mySmtpsvr.Port = "25"
    9. mySmtpsvr.UseDefaultCredentials = False
    10. mySmtpsvr.Credentials = myCredentials
    11. Try
    12. Msg.From = New Net.Mail.MailAddress("Absender")
    13. Msg.To.Add("Empfänger")
    14. Msg.Subject = "Betreff"
    15. Msg.Body = ("Text")
    16. mySmtpsvr.Send(Msg)
    17. Catch ex As Exception
    18. MsgBox("Verbindung fehlgeschlagen! Bitte überprüfe deine Internetverbindung!")
    19. End Try




    Hoffe ich konnte dir helfen.