i'm writing a function to send an email with the option of attachements
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
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: