Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

email without outlook vb6 1

Status
Not open for further replies.

jenohagen

Programmer
Mar 25, 2008
14
US
Hello,
At work we have a program that is built on top of access 2k3. It uses vb6 not vb.net. I have been asked to make a funtion that will email out an report without using outlook. I have made the report and now im researching how to make the function to email. I am having horrible luck. I have found previous posts that give fantastic instructions on where to look ( thread705-1074590, thread181-1412131 ) but they seem to work only for vb.net programs. was excellent also but again it seems to use vb.net. Can someone point me in the right direction on where to look?

Thank you,
Jeno S.
 
If this is in VB6 then you may want to post it in that forum:

forum222

Here are some solutions in the VB5/6 forum but the ones above should work fine as they do not look to be VB.NET.

thread222-1458464
faq222-179

Swi
 
FancyPrairie, in the first thread that you reference, shows you exactly how to do it in VB(A). Although they could have been a little clearer. Here's the example I generally trot out:
Code:
[blue]Option Explicit
[green]' Ensure you have a reference to Microsoft CDO for Exchange 2000
' or to Microsoft CDO for Windows 2000[/green]
 
Private Sub Command1_Click()
    Dim iMsg As CDO.Message
    Dim iConf As CDO.Configuration
    
    Set iMsg = New CDO.Message
    Set iConf = New Configuration 

    [green]'Apply settings to the configuration object[/green]
    With iConf.Fields
        [green]' Don't bother with the following 3 lines of code if the SMTP server you will be connecting to
        ' does not require authentication
        
        ' Specify the authentication mechanism to basic (clear-text) authentication.[/green]
        .Item(cdoSMTPAuthenticate) = cdoBasic
        [green]' The username for authenticating to an SMTP server[/green]
        .Item(cdoSendUserName) = "myusername"
        [green]' The password used to authenticate to an SMTP server[/green]
        .Item(cdoSendPassword) = "mypassword"
        
        [green]' How to send the mail[/green]
        .Item(cdoSendUsingMethod) = cdoSendUsingPort
        [green]'Specify mail server[/green]
        .Item(cdoSMTPServer) = "target.smtpserver.com"
        [green]'Specify the timeout in seconds[/green]
        .Item(cdoSMTPConnectionTimeout) = 10
        [green]' The port on which the SMTP service specified by the smtpserver field is listening for connections (typically 25)[/green]
        .Item(cdoSMTPServerPort) = 25
        
        [green]' Ensure configuration is up to date[/green]
        .Update
    End With

    Set iMsg.Configuration = iConf
    iMsg.To = "destination@email.com"
    iMsg.Subject = "Example"
    iMsg.TextBody = "Hello"
    iMsg.From = "source@home.com"
    
    iMsg.Send
    Set iMsg = Nothing
End Sub[/blue]
 
That was pretty much on target. Thank you for helping me find the needle in the hey stack. Ill try it out and get back to you.
 
I was completely wrong. Once i added the reference of CDO the program worked fine. I am now testing it and being reminded that this is a great forum.

duckman was ahead of his time!
 
Another good thread on this topic:
thread705-1369407
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top