Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Detect user cancels email send
Message
De
03/10/2011 14:52:53
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Divers
Thread ID:
01525141
Message ID:
01525480
Vues:
78
>>I'm pretty sure I've seen the solution to this on UT, but can not track it down.
>>When automating the sending of email via Outlook, how do I detect if the user has closed the email without sending the email?
>>i.e. how do I get a return value from the display() method in the following code, and what would it be in the case of the user aborting the send ?
>>
>>
>>
>>loApplication=CREATEOBJECT("Outlook.Application")
>>loNameSpace=loApplication.GetNameSpace("MAPI")
>>loOutBox=loNameSpace.GetDefaultFolder(4)
>>
>>* Create message object
>>THIS.oMessage=loOutBox.Items.Add
>>WITH THIS.oMessage
>>  .Body=THIS.cBodyText
>>  .Subject=THIS.cSubject
>>  IF llShowOutlook
>>      .display()
>>  ELSE
>>    .Send()
>>  ENDIF
>>ENDWITH
>>
>>
>>Thanks
>>Barry Sutton
>
>See if it helps:
>
>
loApplication=GetOBJECT(,"Outlook.Application")
>lo=loApplication.GetNameSpace("MAPI").GetDefaultFolder(4).Items.Add
>WITH lo
>	.Body="It is a test. Please, ignore"
>	.Subject="Test"
>	lctitle=loApplication.ActiveWindow.caption
>	.display()
>	DO WHILE loApplication.ActiveWindow.caption==lctitle
>		WAIT WINDOW TIMEOUT 1.0 "Waiting for message to appear in Outlook ..."
>	ENDDO
>	lctitle=loApplication.ActiveWindow.caption
>	DO WHILE loApplication.ActiveWindow.caption=lctitle
>		WAIT WINDOW TIMEOUT 1.0 "Waiting for user action..."
>		WAIT WINDOW TIMEOUT 0.3 ""
>	ENDDO
>ENDWITH
>* 
>=MESSAGEBOX(IIF(TYPE("lo.sent")="L" and not lo.sent,"NOT ","")+"Sent")
>
>lo=null
>
>Good Luck

Yuri
Thanks - that works. I had something similar worked out with a TRY..CATCH..ENDTRY and catching for an error on the "sent" property of the message (as it never seems to return .T. as the property is "destroyed" once a message is sent). However, your solution is neater.

Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform