Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using VFPCOM to bind to Outlook events (ItemSend for exa
Message
De
26/04/2000 04:33:57
Walter Meester
HoogkarspelPays-Bas
 
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00363457
Message ID:
00363481
Vues:
19
Andrew,

Probably a shot in the dark, but did you try:

sys(2333,1) or sys(2333,0) ?

Walter,




>Hi Folks,
>
>I'm using VFPCOM to bind to the Outlook Application's ItemSend() event and keep getting a C0000005 error in VFP when I click the Send button in the outlook mail item.
>
>Relevant code is as follows:
>
>In the application object's init:
>
if USE_OUTLOOKINTERFACE and iscomobject('VFPCOM.COMUTIL') and iscomobject('outlook.application')
>  this.oVFPCOM = create('VFPCOM.COMUTIL')
>  this.oOutlook = createobject('outlook.application')
>  this.oOutlookEventHandler = createobject('OutlookApplicationEvents')
>
>  local lcError
>  lcError = this.oVFPCOM.BindEvents(this.oOutlook, this.oOutlookEventHandler)
>	
>  if empty(lcError)
>    this.lUseOutlookInterface = .t.
>  else
>    this.lUseOutlookInterface = .f.
>  endif
>
>else
>
>  this.lUseOutlookInterface = .f.
>endif
>
>In the application object's SendEmail event:
>
with this
>
>  local loMessage
>
>  loMessage = .oOutlook.createitem(olMailItem)
>
>  loMessage.UserProperties.Add('ToContactID', olNumber)
>  loMessage.UserProperties.Add('FromRep', olText)
>  loMessage.UserProperties('ToContactID') = this.GetCurrentContact()
>  loMessage.UserProperties('FromRep') = this.cInitials
>
>  loMessage.Recipients.Add(contactview.email)
>  loMessage.Recipients.ResolveAll()
>  loMessage.Display(.f.)
>
>endwith
>
>All goes well so far, the mail item is displayed (in the background and without the recipient filled in, but I'll get to that next). Hitting the send button in the mail item causes a C0000005 error in VFP.EXE.
>
>The relevant class code for the OutlookApplicationEvents class is:
>
DEFINE CLASS OutlookApplicationEvents AS custom
>
>PROCEDURE ItemSend(Item,Cancel)
>
>* got as far as here once (and then didn't C5!)
>if version(2) > 0
>  set step on
>endif
>
>* if the item is a mail item and it has custom properties ToContactID and FromRep, make a note of its contents in the contact log
>if vartype(Item.UserProperties('ToContactID')) = 'N' and vartype(Item.UserProperties('FromRep')) = 'C'
>
>  local lcAttachments
>  lcAttachments = ''
>  for i = 1 to Item.Attachments.Count
>      lcAttachments = lcAttachments + CR + Item.Attachments(i).DisplayName
>  endfor
>
>  goApp.MakeNote( ;
>    'E', ;
>    Item.UserProperties('ToContactID'), ;
>    'Subject: ' + item.Subject + CR + 'To: ' + item.To + CR + '----' + CR + item.Body + CR + '-Attachments--' + lcAttachments, ;
>    .t., ;
>    .f., ;
>    .f., ;
>    .f., ;
>    .t. ;
>  )
>endif
>
>ENDPROC
>
>[snipped the remaining code (defaults only)]
>
>* I've tried both settings of _VFP.AutoYield.
>* VFP6 SP3
>* Outlook 2000
>* Windows 2000
>
>Any hints would be greatly appreciated.
>
>Cheers,
>
>Andrew
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform