VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Only a few lines of code make you able to use the CDO object and mail wherever you like through SMT

by Gregory Mazarakis (4 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 6th November 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Only a few lines of code make you able to use the CDO object and mail wherever you like through SMTP, in HTML or plain Text. You can also send

API Declarations



'Microsoft CD 1.21 Library' or higher

Rate Only a few lines of code make you able to use the CDO object and mail wherever you like through SMT




    Dim strSubject, strTxtBody, strTo, strCC, strBCC, strAttachFile
    Dim MailServer, MailPort

    MailServer = "MAILSERVER"
    MailPort = 25                       '...probably
    strAttachFile = "c:\Attach.pdf"     'you can comment out the "AddAttachment
    strSubject = "Subject"              'if you dont wish to use
    strTxtBody = "Body"
    strTo = "[email protected];[email protected]"
    
    Set objCDO = CreateObject("CDO.Message")
    Set objCDOConfig = CreateObject("CDO.Configuration")
    Set objFields = objCDOConfig.Fields
    With objFields
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = MailServer
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = MailPort
        .Item("http://schemas.microsoft.com/cdo/configuration/SendUsing") = 2
        .Update
    End With
    With objCDO
        .Configuration = objCDOConfig
        .To = strTo
        .CC = strCC
        .BCC = strBCC
        .From = "[email protected]"
        .Subject = strSubject
        .HTMLBody = strTxtBody
        '.AddAttachment (strAttachFile)
        .Send
    End With
    Set objFields = Nothing
    Set objCDOConfig = Nothing
    Set objCDO = Nothing

End Sub

Download this snippet    Add to My Saved Code

Only a few lines of code make you able to use the CDO object and mail wherever you like through SMT Comments

No comments have been posted about Only a few lines of code make you able to use the CDO object and mail wherever you like through SMT. Why not be the first to post a comment about Only a few lines of code make you able to use the CDO object and mail wherever you like through SMT.

Post your comment

Subject:
Message:
0/1000 characters