0

I currently have a script that goes through a whole folder I specify in my Outlook Mailbox to read the senders email, fullname, time and body of each email.

Works great no issues, but is it possible that I can use a 'wscript argument' to drop one email file on the script to then display it for me?

How would I do it? I cant work out a step by step process in my head to complete this?

the start of my script is like this...

Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNameSpace("MAPI")

Do I have to change this to something or would it not be needed as its from a random mailbox\folder?

Set objFolder = objNameSpace.Folders("Mailbox - Pavle Stojanovic").Folders("Inbox").Folders("Test") 
Set colItems = objFolder.items
' -------------------------------------------------

For Each item in colItems

' Get email data and display how I need it to be......

Next
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Pavle Stojanovic
  • 525
  • 2
  • 8
  • 30

1 Answers1

0

So I pretty much solved my own issue but more Googling.......

I have the basic parts to then later do what i need with my email data...

instead of a drag and drop I have to have the email open...which I can live with.

found it on the msdn site, just modified a little :)

Sub DisplayMsgValues()
 Dim myItem As Outlook.Inspector
 Dim objItem As Object

 Set myItem = Application.ActiveInspector

 If Not TypeName(myItem) = "Nothing" Then

  Set objItem = myItem.CurrentItem

  sSubject = objItem.Subject
  sSender = objItem.SenderName
  sReceivedDate = objItem.ReceivedTime
  sEmail = Split(objItem.SenderEmailAddress, "=")


  Debug.Print sSubject
  Debug.Print sSender
  Debug.Print sReceivedDate
  Debug.Print sEmail(4)
  Debug.Print objItem.Body

 Else
  MsgBox "There is no current active inspector."
 End If

End Sub
Pavle Stojanovic
  • 525
  • 2
  • 8
  • 30