29. april 2012 - 22:59Der er
4 kommentarer og 1 løsning
Problem med System.Net.Mail kan ikke sende en besked
Hej
Jeg kan ikke sende denne besked fra min aspx side. den henter fint den adresse ind i addedemailtext.Text som den skal sende til.
Og når jeg kigger på SMTP Client, så skulle den være rigtig.
Nogle der kan hjælpe !? 'Sending mail to user Dim mailSMTPClient As New SmtpClient("smtp.mail.yahoo.com", 995) Dim mailFromAddress As New MailAddress("test@domain.com") Dim mailToAddress As New MailAddress(addedemailtext.Text) Dim mailMessage As New MailMessage(mailFromAddress, mailToAddress) With mailMessage .Subject = "Test" .Body = "Hello! This is a test." .Priority = MailPriority.Normal .IsBodyHtml = True End With With mailSMTPClient .DeliveryMethod = SmtpDeliveryMethod.Network .Send(mailMessage) End With
Jeg får en timeout så rettede jeg lidt i koden, men fortsat timeout.
Når jeg trykker på en send knap så "loader" den i ca. 20-30 sek. og laver en timeout, via Microsoft VWD 2010 Express, siger den så: SmtpException was unhandled by user code, Handling blev afbrudt pga. timeout.
Ang. SMTP så skulle det være de rigtige oplysninger i.flg. Google.
Dim mailSMTPClient As New SmtpClient() Dim mailFromAddress As New MailAddress("test@domain.com") Dim mailToAddress As New MailAddress(addedemailtext.Text) Dim mailMessage As New MailMessage(mailFromAddress, mailToAddress) With mailMessage .Subject = "Test" .Body = "Hello! This is a test." .Priority = MailPriority.Normal .IsBodyHtml = True End With With mailSMTPClient .Host = "smtp.gmail.com" .EnableSsl = True .Port = 465 .DeliveryMethod = SmtpDeliveryMethod.Network .Send(mailMessage) End With
Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() Dim Password As String = InputBox("Password") Me.Refresh() SmtpServer.Credentials = New _ Net.NetworkCredential("test@gmail.com", Password) SmtpServer.Port = 587 SmtpServer.Host = "smtp.gmail.com" SmtpServer.EnableSsl = True mail = New MailMessage() mail.From = New MailAddress("Test@gmail.com") mail.To.Add("Test@Gmail.com") mail.Subject = "Test Mail" mail.Body = "This is for testing SMTP mail from GMAIL" SmtpServer.Send(mail)
Efter at have kigget lidt på dit, lavede jeg dette og det virker, vil du smide et svar og mange tak.
'Sending mail to user Dim mailSMTPClient As New SmtpClient() Dim mailFromAddress As New MailAddress("test@domain.com") Dim mailToAddress As New MailAddress(addedemailtext.Text) Dim mailMessage As New MailMessage(mailFromAddress, mailToAddress) With mailSMTPClient .Host = "smtp.gmail.com" .EnableSsl = True .Port = 587 .DeliveryMethod = SmtpDeliveryMethod.Network .Credentials = New NetworkCredential("minmail@gmail.com", "min kode") End With With mailMessage .Subject = "Test" .Body = "Hello! This is a test." .Priority = MailPriority.Normal .IsBodyHtml = True End With mailSMTPClient.Send(mailMessage)
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.