Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Outlook
Message
From
24/10/2012 15:16:56
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01555671
Message ID:
01555724
Views:
52
Thanks Hugo.



>>Hi All,
>>
>>How can I use COM automation to get the users primary email address from his Outlook application? Thanks.
>
>I wrote this code long time ago, but I think I replaced for something else later, but I forgot... Anyways, as you are asking for Outlook... it needs redemption in order to avoid the security check from Outlook, if you are using other way to by pass it (like YesNo) then you can remove the redemption related code.
>
>
>
>? getSenderEMail(GetEnv("USERNAME"))
>
>function getSenderEMail(tcSender as String) as Object
>	local loOF, loMailItem, loOutlook, loItem, lcEMailAddress, loException, lcLastError
>	
>	loMailItem	= CreateObject("Redemption.SafeMailItem")
>	loOutlook	= Createobject('Outlook.Application')
>	loItem		= loOutlook.CreateItem(0)
>	loMailItem.Item	= loItem
>	lcEMailAddress	= ''
>	try
>		loMailItem.Recipients.Add(tcSender)
>		if loMailItem.Recipients(1).Resolve()
>			with loMailItem.Recipients(1).AddressEntry
>				lcEMailAddress	= .Name + ' <' + .SMTPAddress + '>'
>			endwith
>		else
>			* Unable to resolve
>		endif
>	catch to loException
>		lcLastError	= Proper(This.Class) + " has encountered a problem." + Chr(13) ;
>						+ "Error Number: " + Transform(loException.ErrorNo) + Chr(13) ;
>						+ "Module: " + 'getSenderInfo' + Chr(13) ;
>						+ "Line: " + Alltrim(Str(loException.LineNo)) + Chr(13) ;
>						+ "Description: " + laError[2]
>
>		MessageBox(lcLastError)
>	endtry
>	return lcEMailAddress
>endfunc
>
>
In the End, we will remember not the words of our enemies, but the silence of our friends - Martin Luther King, Jr.
Previous
Reply
Map
View

Click here to load this message in the networking platform