Hi,
I am trying to send new msg with the details of the old msg and additional info . Below the VBA code...seem to work fine but fails suddenly with sending few messages with run script error.
below is the code ...kindly let me know where the problem is
Public Sub SendReport(Item As Outlook.MailItem)
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
objMsg.HTMLBody = Item.HTMLBody
objMsg.Subject = Item.Subject + "dasfsdfasdfsd"
If Item.Attachments.Count > 0 Then
Dim objAttachments As Outlook.Attachments
Set objAttachments = Item.Attachments
For Each objAttach In objAttachments
' Does not handle duplicate filename scenarios
objAttach.SaveAsFile "D:\stat_test\" & objAttach.FileName
objMsg.Attachments.Add "D:\stat_test\" & objAttach.FileName
Next
Set objAttachments = Nothing
End If
objMsg.Recipients.Add "test@test.com"
objMsg.Send
Set objAttachments = Nothing
Set Item = Nothing
Set objMsg = Nothing
End Sub
I am trying to send new msg with the details of the old msg and additional info . Below the VBA code...seem to work fine but fails suddenly with sending few messages with run script error.
below is the code ...kindly let me know where the problem is
Public Sub SendReport(Item As Outlook.MailItem)
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)
objMsg.HTMLBody = Item.HTMLBody
objMsg.Subject = Item.Subject + "dasfsdfasdfsd"
If Item.Attachments.Count > 0 Then
Dim objAttachments As Outlook.Attachments
Set objAttachments = Item.Attachments
For Each objAttach In objAttachments
' Does not handle duplicate filename scenarios
objAttach.SaveAsFile "D:\stat_test\" & objAttach.FileName
objMsg.Attachments.Add "D:\stat_test\" & objAttach.FileName
Next
Set objAttachments = Nothing
End If
objMsg.Recipients.Add "test@test.com"
objMsg.Send
Set objAttachments = Nothing
Set Item = Nothing
Set objMsg = Nothing
End Sub