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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending email

Status
Not open for further replies.

Moss100

Technical User
Aug 10, 2004
586
GB
Hello all.

Currently I uses Chilkat to send emails from within Access (generally from a pop up form). (Stmp)

We use windows live mail rather than outlook.

Whilst generally ok, I find on occasions the email to be unreliable.

I am interested to learn of the 'best' way to send emails from within access, preferably not using Outlook.

I am also interested to learn whether others feel that we would benefit from using outlook (from a reliability point of view)

Many thanks for any tips and wisdom. Mark
 
I only use Outlook for sending email through my Access apps and have written an email wrapper class to achieve this which you may find helpful

faq705-7667

It's worth noting that you need to ensure you have the application in the trusted locations regkey, to stop that annoying outlook security pop-up.

I have no experience with doing it direct with MAPI and Exchange or SMTP, so cannot advise on those methods.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
With Exchange server, you can add the reference to Microsoft CDO for Windows 2000 Library and use this code (provide your own CDO.cdoSMTPServer):

Code:
Sub SendAMessage(strFrom As String, strTo As String, _
    strCC As String, strSubject As String, strTextBody As String, _
    Optional strBcc As String, Optional strAttachDoc As String)
Dim objMessage As CDO.Message

On Error GoTo MyErrorHadler

Set objMessage = New CDO.Message

With objMessage
    .From = strFrom
    .To = strTo
    If Len(Trim$(strCC)) > 0 Then
        .CC = strCC
    End If
    If Len(strBcc) > 0 Then
        .BCC = strBcc
    End If[green]
    ''' On behalf of
    '.Sender = "Cheryl.Smith@abc.com"[/green]
    .Subject = strSubject
    .TextBody = strTextBody
    
    If Len(strAttachDoc) > 0 Then
        .AddAttachment strAttachDoc
    End If
    
    With .Configuration.Fields
        .Item(CDO.cdoSMTPServer) = [red]"NTSMTP.ABC.XYZ.LAN"[/red]
        .Item(CDO.cdoSMTPServerPort) = 25
        .Item(CDO.cdoSendUsingMethod) = CDO.cdoSendUsingPort
        .Item(cdoSMTPConnectionTimeout) = 10
        .Update
    End With
    .Send
End With

Set objMessage = Nothing

Exit Sub
MyErrorHadler:

End Sub

Have fun.

---- Andy
 
>With Exchange server

You don't necessarily need Exchange. And it looks as if the OPs mail is hosted by their ISP rather than Exchange, so they can use your code and would simply need to modify:

.Item(CDO.cdoSMTPServer) = "NTSMTP.ABC.XYZ.LAN"

to point to the SMTP host they already use
 
CDO 2.0 (i.e Microsoft CDO for Windows 2000 Library) isn't deprecated as far as I know. The earlier CD0 1.21 is, though.
 
ahh yes, I think I used to use 1.21 before moving over to OOM when Office 2007 came out as the CDO reference I was using was no longer available and it wouldn't let me use the 1.21 anymore.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Free Dance Music Downloads
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top