Send E-Mail without useing a service that has to store those e-mail addresses

Posted on 2006-04-06
Last Modified: 2010-08-05
I am currently using MS Exchange to send e-mails automaticly in a VB app, The draw back is that I have to add every address to exchange so that i can send the mail. I am looking for a way to send mail without haveing to store the e-mail address in a location other than my database.

Thanks for your help,
Question by:icserve
    LVL 28

    Expert Comment

    What method are you using to send the e-mail?
    LVL 69

    Expert Comment

    by:Éric Moreau
    Hi icserve,

    try this component:      

    LVL 1

    Author Comment

    Public Function SendSMTP(SMTP_Server$, MailFrom$, From$, Addresses$, Subject$, Body$, Attachment$, Messages$) As Boolean
        On Error Resume Next
        SMTPMessages = ""
        ChDrive App.Path
        ChDir App.Path
        SetPrintFunc FnPtr(AddressOf PrintBlat)
        If Err Then
            MsgBox "Can't load BLAT.DLL"
            Exit Function
        End If
        Dim argv As StringArray
        argv.STRINGS(0) = "blat.dll"
        argv.STRINGS(1) = "-"
        argv.STRINGS(2) = "-server"
        argv.STRINGS(3) = SMTP_Server
        argv.STRINGS(4) = "-mailfrom"
        argv.STRINGS(5) = MailFrom
        If Len(Addresses) Then
            argv.STRINGS(6) = "-To"
            argv.STRINGS(7) = Addresses
            Messages = "No recipients."
            Exit Function
        End If
        argv.STRINGS(8) = "-s"
        argv.STRINGS(9) = Subject
        argv.STRINGS(10) = "-body"
        argv.STRINGS(11) = Body
        argv.STRINGS(12) = "-from"
        argv.STRINGS(13) = From
        argv.STRINGS(14) = "-mime" ' "-html" '"-enriched" '"-mime"
        argv.STRINGS(15) = "-binary"
        argv.STRINGS(16) = "-attach"
        argv.STRINGS(17) = Attachment
        Dim ret&
        ret = Blat(18, argv)
        If ret Or Err Then
            Messages = SMTPMessages + vbCrLf + "Sending e-mail via SMTP (BLAT.DLL) failed: " + CStr(ret)
            Exit Function
        End If
        SendSMTP = True
        Messages = SMTPMessages
    End Function
    LVL 28

    Expert Comment

    It looks like the above is calling the Blat function to send the mail. Why can't you just read the records from your database and pass them to the SendSMTP function?
    LVL 76

    Expert Comment

    by:David Lee
    Hi icserve,

    > I have to add every address to exchange so that i can send the mail
    Are you talking about the address of the sender or of the intended recipient?  If the latter, then I don't follow why.  I send messages to addresses that aren't in Exchange all the time via VB.

    LVL 5

    Accepted Solution

    you can achieve this with CDO (Collaboration Data object)

    have a look here

    But here's a pretty basic sample of code

    'use CDO to send emails silently....**N.B-will not go to users sentItems**
    Public Function bSendEmail(ByVal sEmail As String, ByVal sSubject As String, ByVal sBody As String, _
                Optional ByVal sPathFileName As String, Optional sFrom As String) As Boolean
    Dim objMessage As New CDO.Message
        Dim iConf As CDO.Configuration

    On Error GoTo Err_bSendEmail
        With objMessage    
            Set iConf = objMessage.Configuration
            'Set the fields of the configuration object to send using SMTP via port 25.
            With iConf.Fields
                .Item("") = cdoSendUsingPort
                .Item("") = mySTMPServer
                .Item("") = 25 'mail port
                .Item("") = cdoAnonymous
            End With
            .To = sEmail
            .From = sFrom
            .Subject = sSubject
            .TextBody = sBody
        End With
        bSendEmail = True

        If Err.Number <> 0 Then
             MsgBox Err.Description, , Err.Source
             bSendEmail = False
        End If
        Set objMessage = Nothing
        Set objFSO = Nothing
    End Function

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now