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. endifIn 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.) endwithAll 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.
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.