Hi All
Sorry other question, I have this code:
This code takes the highlighted emails in a users Outlook, and asks them if they want to send the whole email or not. If they hit YES then the entire email is saved to a directory, if they hit NO then just the attachments of that email is saved to the same directory... It then asks the same question on the next email in their highlighted selection.
This works perfectly as planned. But further along I am building in some cancel features... And my question is, how can I save each *.msg file saved full path and each attachments full path into their own variable?
The plan is that if each time Outlooks saves (either a .msg or an attachment) it saves the full path into a variable, which later on down the code if the user hits cancel... Then I can run some "Kill" commands to delete all the files that were saved down.
I think I can code this myself using: "Dim emailarray(1 To objSelection.Count) As Integer" & "Dim filearray(1 To lngCount) As Integer"
But that would require scrapping the "For Each objMsg In objSelection" loop for a "For e = 1 to objSelection.Count" loop working with objMsg? But I don't know how to do that?
If you have any ideas or other solutions would be greatly appreciated.
Thanks
Sorry other question, I have this code:
Code:
Set objOL = CreateObject("Outlook.Application")Set objSelection = objOL.ActiveExplorer.Selection
For Each objMsg In objSelection
ans = MsgBox("Sender: " & objMsg.SenderName & vbNewLine & "Subject: " & objMsg.Subject & vbNewLine & "Received: " & objMsg.ReceivedTime & " ", vbYesNo, "Do you want to send this entire email?")
If ans = vbYes Then
mailfile = objMsg.SenderName & ".msg"
objMsg.SaveAs strFolderpath & mailfile, olMSG
Else
Set objAttachments = objMsg.Attachments
lngCount = objAttachments.Count
If lngCount > 0 Then
For i = lngCount To 1 Step -1
strFile = objAttachments.Item(i).FileName
strFile = strFolderpath & strFile
objAttachments.Item(i).SaveAsFile strFile
Next i
End If
End If
Next
This code takes the highlighted emails in a users Outlook, and asks them if they want to send the whole email or not. If they hit YES then the entire email is saved to a directory, if they hit NO then just the attachments of that email is saved to the same directory... It then asks the same question on the next email in their highlighted selection.
This works perfectly as planned. But further along I am building in some cancel features... And my question is, how can I save each *.msg file saved full path and each attachments full path into their own variable?
The plan is that if each time Outlooks saves (either a .msg or an attachment) it saves the full path into a variable, which later on down the code if the user hits cancel... Then I can run some "Kill" commands to delete all the files that were saved down.
I think I can code this myself using: "Dim emailarray(1 To objSelection.Count) As Integer" & "Dim filearray(1 To lngCount) As Integer"
But that would require scrapping the "For Each objMsg In objSelection" loop for a "For e = 1 to objSelection.Count" loop working with objMsg? But I don't know how to do that?
If you have any ideas or other solutions would be greatly appreciated.
Thanks