Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Email address from Outlook instead of the LegacyDN - VBScript

Status
Not open for further replies.

PavleStojanovic

Programmer
Oct 22, 2012
1
AU
Hey Guys,

I have created this below (with help from the internet :) )
it works fine (external emails) but when I use this at work for our internal emails,
I don't get the email but I get (something like this):

/o=pavlesdomain/ou=first administrative group/cn=recipients/cn=exampleuser

can someone help me just get the email address ?

and then after this I am querying AD for the userID from the email which I worked out...ill post that if you all want to....

but if you can also tell me how to get the Alias section (this is where the UserID id for us) ?


Thanks
Pavle.

Code:
' -------------------------------------------------
' 	Setting Mailbox to read
'     ---------------------------
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNameSpace("MAPI")
Set objFolder = objNameSpace.Folders("Mailbox - Pavle Stojanovic").Folders("Inbox").Folders("Test")
Set colItems = objFolder.items
' -------------------------------------------------

For Each item in colItems

       ' -----------------------------------------------------
       ' 	Items to grab from the emails
       '      ---------------------------------
	EmailSubject = item.subject			' Subject Line
	EmailSenderName = item.SenderName		' Name of sender
	EmailSenderAddress = item.SenderEmailAddress	' Senders Email Address
	EmailBody = item.Body				' Content of the email
       ' -----------------------------------------------------

  If item.Unread = True Then

If EmailSubject = "Code: 12345" Then

		' THIS IS WHERE I WANT TO EXPORT DATA 
		' BUT FOR NOW DISPLAYING IN A MESSAGE BOX

	MsgBox  "Email Subject: " & EmailSubject & vbCr & _
		"Senders Name: " & EmailSenderName & vbCr & _ 
	 	"Senders Email Address: " & EmailSenderAddress & vbCr & _ 
		"Body Of Email: " & vbCr & _ 
		 EmailBody

item.Subject = item.Subject & " Modifed by Pavle"

  item.Unread = False   ' Setting email as a "read" item...

 End If
End If
  item.Save
Next


Wscript.Quit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top