Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   С/С++, C#, Delphi, .NET, Asm (https://forum.antichat.xyz/forumdisplay.php?f=24)
-   -   Отправить письмо.vb.net (https://forum.antichat.xyz/showthread.php?t=156689)

DJ4J 15.11.2009 14:28

Отправить письмо.vb.net
 
подскажите плиз как отправлять письмо на мыло из vb.net
пробовал сам писать,вообще не компилирует :(
и поподробнее плз)

DeaD_MoroZ 17.11.2009 06:03

Код:

'Read the text of message and signature from txt-file "MessText.txt"
 
Set fso = CreateObject("Scripting.FileSystemObject")
'Open the file for reading
Set f = fso.OpenTextFile("c:\Apps\MessText.txt", ForReading)
'The ReadAll method reads the entire file into the variable BodyText
MessText = f.ReadAll
'Close the file
f.Close
Set f = Nothing
Set fso = Nothing
'____________________________________________________________________________________
 
'Read the recipients of Distribution List from txt-file:
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile("c:\Apps\DistrList.txt", ForReading)
DistribList = f.ReadAll
f.Close
Set f = Nothing
Set fso = Nothing
'____________________________________________________________________________________
 
 
AttFile = ("C:\Apps\Temp\Test_attach.txt")          'Path to file-attachment
Set objEmail = WScript.CreateObject("CDO.Message")  'Create CDO-object and get link on it into objEmail (var)
 
''''''''''''''''''''''''''''''''''''''''''''''''''''
' Required parameters of CDO-object
''''''''''''''''''''''''''''''''''''''''''''''''''''
objEmail.From = "MyAddress@shell.com"                        'Sender (mine) address
'objEmail.To = DistribList                                    'Address of recipient or distribution list
objEmail.BCC = "address@mail.com"                            'Hide copy recipient address
objEmail.Subject = "Field Management Report " & DateSubj      'Subject of message
objEmail.AddAttachment = AttFile                              'Attachment
objEmail.TextBody = MessText                                  'Message Text
objEmail.BodyPart.Charset = "windows-1251"                    'Cyrillic encoding
 
 
'Sending message using SMTP-service (1 - using of local SMTP-service)
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'Name of SMTP-server
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SLMCPF-S-01001"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "MyAddress@shell.com"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""
 
 
 
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25  'Port of SMTP-server
objEmail.Configuration.Fields.Update          'Update configuration of CDO-object
objEmail.Send    'Sending of message by using Send-method



Время: 11:04