Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Outlook
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01555671
Message ID:
01555710
Vues:
69
This message has been marked as a message which has helped to the initial question of the thread.
>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
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform