Need help with email function

Russ9517

Registered User.
Local time
Today, 11:29
Joined
Sep 15, 2006
Messages
30
i'm writing a function to send an email with the option of attachements in microsoft access using vba. This is the code i'm using, it works fine but i need to be able to sne mulitple attachments. What would be the best way of doing this?

Thanks

code:
Public Function SendEmail(strTo As String, strSubject As String, strBody As String, Optional strCC As String, Optional strAttached As String)
Dim olkapps As Outlook.Application
Dim olknamespaces As Outlook.Namespace
Dim objmailitems As Outlook.MailItem
Set olkapps = New Outlook.Application
Set olknamespaces = GetNamespace("MAPI")
Set objmailitems = olkapps.CreateItem(olMailItem)
With objmailitems
.To = strTo
If IsNull(strCC) = False Then
.CC = strCC
End If
.Subject = strSubject
.Body = strBody
If IsNull(strAttached) = False Then
.Attachments.Add strAttached
End If
.Send
End With
Set objmailitems = Nothing
Set olknamespaces = Nothing
Set olkapps = Nothing
End Function
 
Last edited:
re:

Hi,
Just repeat your code to add as many as you want e.g.:

...
.Attachments.Add strAttached
.Attachments.Add strAttached01
.Attachments.Add strAttached02
...

HTH
Good luck
 

Users who are viewing this thread

Back
Top Bottom