Отправить письмо.vb.net

Discussion in 'С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby' started by DJ4J, 15 Nov 2009.

  1. DJ4J

    DJ4J Member

    Joined:
    23 Aug 2009
    Messages:
    2
    Likes Received:
    53
    Reputations:
    1
    подскажите плиз как отправлять письмо на мыло из vb.net
    пробовал сам писать,вообще не компилирует :(
    и поподробнее плз)
     
  2. DeaD_MoroZ

    DeaD_MoroZ Banned

    Joined:
    3 Nov 2009
    Messages:
    102
    Likes Received:
    7
    Reputations:
    0
    Code:
    '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
    
     
    #2 DeaD_MoroZ, 17 Nov 2009
    Last edited by a moderator: 17 Nov 2009