Для того что бы отправить письмо из программы на указанный почтовый ящик необходимо:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
Imports System.Net.Mail Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click SendEmail1() End Sub Function SendEmail() Dim msg As Object Dim config As String Set msg = CreateObject("CDO.Message") msg.BodyPart.Charset = "windows-1251" config = "http://schemas.microsoft.com/cdo/configuration/" With msg .To = "email -Адрес получателя" .From = "email - Адрес отправителя" .Subject = "Тема письма" .TextBody = "Текст письма" .AddAttachment ("Файл - Вложение1") '.AddAttachment ("Файл - Вложение2") With .Configuration.Fields .Item(config & "sendusing") = 2 .Item(config & "smtpserver") = "smtp.gmail.com" 'yandex.ru, mail.ru .Item(config & "smtpauthenticate") = 1 .Item(config & "smtpserverport") = 25 .Item(config & "sendusername") = "email - Адрес отправителя" .Item(config & "sendpassword") = "Пароль от email - почтового ящика" .Item(config & "smtpusessl") = True '(yandex.ru, mail.ru =False) .Item(config & "smtpconnectiontimeout") = 60 .Update End With .send End With Set msg = Nothing End Function |