Hi,
I am trying to save a email to specific folders based on the email subject.
I have the following code.
I can get it to work if the email subject is only ?H1221? if the subject is ?H1221 Delivery Dates? then it stops working I have tried using wildcards * & ? but this does not seem to work? Any help would be greatly appreciated.
Many thanks,Sub SaveAs_msg() Dim myItem As Outlook.Inspector Dim objItem As Object Set myOlApp = CreateObject("Outlook.Application") Set myItem = myOlApp.ActiveInspector If Not TypeName(myItem) = "Nothing" Then Set objItem = myItem.CurrentItem strname = objItem.Subject 'Prompt the user for confirmation Dim strPrompt As String strPrompt = "Are you sure you want to save the item? If a file with the same name already exists, it will be overwritten with this copy of the file." If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then 'objItem.SaveAs "C:\" & strname & ".msg", olMSG 'If objItem.Subject = "H1221" Then ? this work if subject is only ?H1221 If objItem.Subject = "H1221 *" Then ? this is meant to work if the subject is ?H1221 delivery dates? objItem.SaveAs "Z:\H1221\" & strname & ".msg", olMSG End If End If Else MsgBox "There is no current active inspector." End If End Sub
Colin,



Reply With Quote
