forked from Wuwqhnsya/Dictator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_email.vbs
35 lines (33 loc) · 1019 Bytes
/
get_email.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Sub Main()
Dim SavePath
Dim Subject
Dim FileExtension
Dim counter
Dim objFileToWrite
Dim list
Set list = CreateObject("System.Collections.ArrayList")
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFolder = objNamespace.GetDefaultFolder(6)
Set colItems = objFolder.Items
counter=0
For Each objMessage In colItems
Dim sub_str
sub_str = Mid(objMessage.Body,1,150)
sub_str=sub_str & "**###**###"
list.Add "Subject : " & objMessage.Subject & "Body : " & sub_str
Next
list.Reverse
Set objFileToWrite = CreateObject("Scripting.FileSystemObject").OpenTextFile("D:\emails.txt",8,true)
For Each subj In list
'WScript.Echo subj
objFileToWrite.WriteLine(subj)
counter=counter+1
If counter > 10 Then
Exit For
End If
Next
objFileToWrite.Close
Set objFileToWrite = Nothing
End Sub
Main()