Murray Brown
asked on
Excel VBA - determine whether an Outlook message displayed is actually sent
Hi. I have an Outlook message declared as follows in Excel VBA. It then is displayed in the second line. How do I determine if the message is actually sent?
Dim Msg As Outlook.MailItem
Msg.Disply
Dim Msg As Outlook.MailItem
Msg.Disply
ASKER
Hi. Thanks, I am actually looking to detect programmatically whether the email was sent. Sorry for not explaining that clearly
I saw this link but am not sure how to implement it
http://stackoverflow.com/questions/2533066/vba-outlook-mail-display-recording-when-if-sent-manually
I saw this link but am not sure how to implement it
http://stackoverflow.com/questions/2533066/vba-outlook-mail-display-recording-when-if-sent-manually
Here is a sample that will loop thru an Outlook folder:
Sub Download_Outlook_Mail_To_Excel()
'Add Tools->References->"Microsoft Outlook nn.n Object Library"
'nn.n varies as per our Outlook Installation
Dim Folder As Outlook.MAPIFolder
Dim iRow As Integer
'Mailbox or PST Main Folder Name (As how it is displayed in your Outlook Session)
MailBoxName = "MailBox Name"
'Mailbox Folder or PST Folder Name (As how it is displayed in your Outlook Session)
Pst_Folder_Name = "Folder Name" 'Sample "Inbox" or "Sent Items"
Set Folder = Outlook.Session.Folders(MailBoxName).Folders(Pst_Folder_Name)
If Folder = "" Then
MsgBox "Invalid Data in Input"
GoTo end_lbl1:
End If
'Rad Through each Mail and export the details to Excel
Sheets(1).Activate
Folder.Items.Sort "Received"
For iRow = 1 To Folder.Items.Count
Sheets(1).Cells(iRow, 1).Select
Sheets(1).Cells(iRow, 1) = Folder.Items.Item(iRow).SenderName
Sheets(1).Cells(iRow, 2) = Folder.Items.Item(iRow).Subject
Sheets(1).Cells(iRow, 3) = Folder.Items.Item(iRow).ReceivedTime
Sheets(1).Cells(iRow, 4) = Folder.Items.Item(iRow).Size
'Sheets(1).Cells(iRow, 5) = Folder.Items.Item(iRow).SenderEmailAddress
'Sheets(1).Cells(iRow, 6) = Folder.Items.Item(iRow).Body
Next iRow
MsgBox "Outlook Mails Extracted to Excel"
end_lbl1:
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you very much for taking all the time out to show me. Much appreciated!
My pleasure!
If you want to send it use
Msg.Send and not Msg.Display (note you have a typo).