[AccessD] E-mail Report

John W. Colby jwcolby at colbyconsulting.com
Wed May 18 08:54:20 CDT 2005


This function will allow you to send an email if you have Outlook installed
and referenced.  I yanked this out of a class and lightly modified it to
pass in the strings so it SHOULD work as advertised.

'.Comments  :
'.Parameters:
'.Sets      :
'.Returns   :
'.Created by: John W. Colby
'.Created   : 3/7/02 12:06:52 PM
Function Mailit(mstrEMTo as string, mstrEMSubj as string, mstrEMBody as
string, optional strAttachmentFilename as string) As Boolean
On Error GoTo Err_Mailit
Dim strAttachmentFilename As String

    Dim myOlApp As Outlook.Application
    Set myOlApp = OpenOL()
    Dim myOLItem As Outlook.MailItem
    Set myOLItem = myOlApp.CreateItem(olMailItem)
    With myOLItem
        .To = mstrEMTo
        .Subject = mstrEMSubj
        .Body = mstrEMBody
        If Len(strAttachmentFilename) > 0 Then
            .Attachments.Add strAttachmentFilename
        End If
    End With
    myOLItem.Send
    Mailit = 1
Exit_Mailit:
On Error Resume Next
    Set myOLItem = Nothing
Exit Function
Err_Mailit:
    Select Case Err
    Case 0      '.insert Errors you wish to ignore here
        Resume Next
    Case Is < 0 'Can't find attachment (file not there to attach)
        Resume Exit_Mailit
    Case 287
        Resume Exit_Mailit
    Case Else   '.All other errors will trap
        Beep
        MsgBox Err.Description, , "Error in Function basATPReport.Mailit"
        Resume Exit_Mailit
    End Select
    Resume 0    '.FOR TROUBLESHOOTING
End Function

John W. Colby
www.ColbyConsulting.com 

Contribute your unused CPU cycles to a good cause:
http://folding.stanford.edu/

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gowey Mike W
Sent: Wednesday, May 18, 2005 9:42 AM
To: Access Developers discussion and problem solving
Subject: [AccessD] E-mail Report


 
Is there a way to run a query from a customer table and grab the e-mail
address of certain customers and e-mail each one of them a report/letter.

Any help would be greatly appreciated.

Thanks in advance,

Mike Gowey  MCDST, A+, LME, NET+
Team Leader - East Region
Information Systems Unit

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com






More information about the AccessD mailing list