Например пробовал вот это
- Код: Выделить всё
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 smtpServer As New SmtpClient()
Dim mail As New MailMessage()
smtpServer.Credentials = New Net.NetworkCredential("alex******@gmail.com", "******")
'using gmail
smtpServer.Port = 587
smtpServer.Host = "smtp.gmail.com"
smtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("alex*******@gmail.com")
mail.To.Add("alexr*******@gmail.com")
mail.Subject = ("blablabla")
mail.Body = TextBox1.Text
smtpServer.Send(mail)
MsgBox("Mail Sent Succesfull!")
End Sub
End Class
ругается на smtpServer.Send(mail)
System.Net.Mail.SmtpException was unhandled
Message="Сбой при отправке сообщения электронной почты."
Source="System"
StackTrace:
в System.Net.Mail.SmtpClient.Send(MailMessage message) в WindowsApplication1.Form1.Button1_Click(Object sender, EventArgs e) в C:\Users\Ecu\AppData\Local\Temporary Projects\WindowsApplication1\Form1.vb:строка 17 в System.Windows.Forms.Control.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.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(Int32 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) в 17d14f5c-a337-4978-8281-53493378c1071.vb:строка 81 в System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) в Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() в System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) в System.Threading.ThreadHelper.ThreadStart()
InnerException: System.FormatException
Message="Недопустимый знак в заголовке электронной почты."
Source="System"
StackTrace:
в System.Net.BufferBuilder.Append(String value, Int32 offset, Int32 count) в System.Net.Mail.EHelloCommand.PrepareCommand(SmtpConnection conn, String domain) в System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) в System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException: