Page 1 of 1

Find string inside outlook .msg and inside archive .zip extensions

Posted: 09 Jan 2019, 04:30
by blue83
Hi,

Can anyone help and show me a way how to find a string inside outlook .msg and inside archive .zip.

My problem is that I have thousands of files with extension .msg and .zip, and is there any way to search through them fast?

In outlook .msg there are attachements like excel, pdf, word,.. and sometimes aren`t, just email body.

In archive .zip there are also various file types.

Blue83

Re: Find string inside outlook .msg and inside archive .zip extensions

Posted: 11 Jan 2019, 08:26
by blue83
Ok, I can manage with .zip, but .msg outlook is still a problem.

I have thousands of files saved in folder, but dont know how search through them and find what I want.

Can anyone help me?

Re: Find string inside outlook .msg and inside archive .zip extensions

Posted: 11 Jan 2019, 11:14
by hymal7

Code: Select all

try olApp := ComObjActive("Outlook.Application") ; Get the Outlook application object if Outlook is open
catch {
		olApp  := ComObjCreate("Outlook.Application") ; Create an Outlook application object if Outlook is not open
		CloseOutlook := true
	}
Loop, % A_Desktop "\*.msg"
{
	item := olApp.CreateItemFromTemplate(A_LoopFileFullPath)
	BodyMessage := item.Body
	Title := item.subject
	
	if instr(BodyMessage,"Mike")		;If there is "Mike" in the email body
	{
		msgbox %title%					;Do something: e.g. show the email title
	}
}
if (CloseOutlook)
    olApp.Quit

;#######################################################################
exitapp
esc::ExitApp

Re: Find string inside outlook .msg and inside archive .zip extensions

Posted: 12 Jan 2019, 06:13
by blue83
Thank you hymal7.

That is for body and excellent.

Do you know how to extract attachements into some folder?

Re: Find string inside outlook .msg and inside archive .zip extensions

Posted: 12 Jan 2019, 09:18
by Ahk_fan
Hi
try this:

Code: Select all

			
			att_count:=Item.attachments.count
			loop, %att_count%
			{
				try
				{
					att_filename:=Item.attachments(a_index).filename
					storepathname:= A_Scriptdir "\" att_filename
					Item.attachments(a_index).saveasfile(storepathname)
				}
				catch
				{
				MsgBox, 0, OUTLOOK-Export, ooopss...something was wrong...
				}
				
			}

Re: Find string inside outlook .msg and inside archive .zip extensions

Posted: 14 Jan 2019, 04:27
by blue83
Wow thank you Ahk_fan.

This task is successfully solved.