M
Mark
HI having problem with sending more than one attachment
Using the code below that I got off this site
Works fine sending one attachment but I need to add 2
Any ideas please?
-------------------------------------------------------------------------------------
Sub sbSendMessage(Optional attachmentpath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim Subjectdate
Subjectdate = Format(Date, "Long date")
' On Error GoTo ErrorMsgs
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("Mark")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Mark")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = Subjectdate
.Body = "" & vbCrLf & vbCrLf
' Add attachments to the message.
If Not IsMissing(attachmentpath) Then
Set objOutlookAttach = .Attachments.Add(attachmentpath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
'End If
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
'ErrorMsgs:
' If Err.Number = "287" Then
' MsgBox "You clicked No to the Outlook security warning. " & "Rerun
the procedure and click Yes to access e-mail" & "addresses to send your
message. For more information," & "see the document at
http://www.microsoft.com/office" & "/previous/outlook/downloads/security.asp.
"
' Else
' MsgBox Err.Number, Err.Description
' End If
End Sub
Using the code below that I got off this site
Works fine sending one attachment but I need to add 2
Any ideas please?
-------------------------------------------------------------------------------------
Sub sbSendMessage(Optional attachmentpath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
Dim Subjectdate
Subjectdate = Format(Date, "Long date")
' On Error GoTo ErrorMsgs
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("Mark")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Mark")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = Subjectdate
.Body = "" & vbCrLf & vbCrLf
' Add attachments to the message.
If Not IsMissing(attachmentpath) Then
Set objOutlookAttach = .Attachments.Add(attachmentpath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
'End If
End If
Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
'ErrorMsgs:
' If Err.Number = "287" Then
' MsgBox "You clicked No to the Outlook security warning. " & "Rerun
the procedure and click Yes to access e-mail" & "addresses to send your
message. For more information," & "see the document at
http://www.microsoft.com/office" & "/previous/outlook/downloads/security.asp.
"
' Else
' MsgBox Err.Number, Err.Description
' End If
End Sub