Results 1 to 4 of 4

Thread: email capabilites with cdo for exchange in vb6

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    83

    email capabilites with cdo for exchange in vb6

    hey guys
    i'm afraid i'm at a complete loss.
    basically i want to add an email capability to one of my apps

    i've managed to get some code that works but it uses
    code such as:
    .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True

    now from what i understand i substitute the code above with:
    !cdoSMTPUseSSL = True
    once i have referenced the "cdo for windows" library cdosys.dll.

    problem is that i dont have cdosys.dll but have cdoex.dll (cdo for exchange 2000 library) which i understand replaced cdosys.dll (i.e. has the same functionallity and more)

    the code dosnt work however and i get an error message
    cdo error, the sendusing configuration value is invalid

    so i guess what i'm really after is vb6 example code, which sends emails and references "cdo for exchange 2000" library. can anyone point me in the right direction? 4hrs of searching has thrown up very little
    alternativly where can i get cdo for windows library?

    also the code i have which has the schemas.micosoft.com in it, does work but am worried that the code is not "self contained" i.e. it has to look up microsoft.com each time to send a mail??

    thanks for the help yet again!!
    jim
    sdrawkcab daer uoy nac

  2. #2
    PowerPoster Fazi's Avatar
    Join Date
    Aug 2005
    Location
    Underworld
    Posts
    2,525

    Re: email capabilites with cdo for exchange in vb6

    Here is a working CDO Code i use in my project

    This example uses gmail smtp service to send emails

    Code:
    Public Function cdo_email_gmail(smtp As String, port As Long, gwpass As String) As Boolean 'Mail
    
    On Error GoTo err
    
    'Add the Project Reference Miscrosoft CDO WINDOWS FOR 2000
    
    Dim lobj_cdomsg As CDO.message
    Set lobj_cdomsg = New CDO.message
    
    With lobj_cdomsg.Configuration
    .Fields(cdoSMTPServer) = smtp
    .Fields(cdoSMTPConnectionTimeout) = 60
    .Fields(cdoSendUsingMethod) = cdoSendUsingPort
    .Fields(cdoSMTPServerPort) = port '465 works for gmail
    .Fields(cdoSMTPAuthenticate) = True
    .Fields(cdoSMTPUseSSL) = True
    .Fields(cdoSendUserName) = Form2.txtfrom.Text 
    .Fields(cdoSendPassword) = gwpass
    .Fields.Update
    
    Dim toMail As String
    Dim optSubject As String
    Dim body As String
    
    body = "test message"
         
    
    lobj_cdomsg.To = Form2.txtTo
    lobj_cdomsg.From = Form2.txtfrom
    lobj_cdomsg.ReplyTo = Form2.txtfrom
    lobj_cdomsg.Subject = Form2.txtSubject
    lobj_cdomsg.TextBody = vbCrLf & body
    
    lobj_cdomsg.AddAttachment App.path & "\" & "abc.jpg"
    lobj_cdomsg.Send
    
    Set lobj_cdomsg = Nothing
    
    cdo_email_gmail = True
    
    Exit Function
    This code i just using in my projects. so text boxes mensioned here are in my project. modify it to suit your needs.

    i am distributing cdosys.dll in my installation. works well in xp and vista.

    Last edited by Fazi; Oct 2nd, 2008 at 02:53 AM.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2005
    Posts
    83

    Re: email capabilites with cdo for exchange in vb6

    thanks fazi
    you code is pretty much what i was hoping to use,
    except i dont havethe cdo for windows 2000 library
    but i have cdo for exchange 2000 library.
    the code fails when using exchange 2000 library
    thanks all that same
    if i find a soln i'll post back but its not looking good!
    jim
    sdrawkcab daer uoy nac

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: email capabilites with cdo for exchange in vb6

    google cdosys.dll download for many choices
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width