• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 200
  • Last Modified:

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

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,
Kevin
0
icserve
Asked:
icserve
1 Solution
 
vinnyd79Commented:
What method are you using to send the e-mail?
0
 
Éric MoreauSenior .Net ConsultantCommented:
Hi icserve,

try this component: http://www.freevbcode.com/ShowCode.Asp?ID=109       

Cheers!
0
 
icserveAuthor Commented:
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
    Err.Clear
    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
    Else
        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&
    Err.Clear
    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
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
vinnyd79Commented:
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?
0
 
David LeeCommented:
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.

Cheers!
0
 
mah8473Commented:
you can achieve this with CDO (Collaboration Data object)

have a look here www.cdolive.com

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("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mySTMPServer
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'mail port
            .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoAnonymous
            .Update
        End With
       
        .To = sEmail
        .From = sFrom
        .Subject = sSubject
        .TextBody = sBody
        .send
    End With
   
    bSendEmail = True

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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now