Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MAPI Routine Works with Windows Messaging, Not with Outl
Message
 
To
28/11/2001 06:11:23
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
ActiveX controls in VFP
Miscellaneous
Thread ID:
00586701
Message ID:
00587206
Views:
34
>>I have written a routine to send mail from within a Visual FoxPro 6.0 compiled program. It works fine with the old Windows Messaging mail client. But when trying to use it with Outlook being the mail client, the following error message is given:
>>
>>OLE | Dispatch exception code 0 from MAPIMessages:
>>Attachment not found. - Cancel - Ignore - Help
>>
>>Would appreciate any ideas. TIA, Chuck
>
>Chuck,
>Are you sure? It says attachment not found.
>Cetin

Cetin,
Yes, I am sure. I got a screen shot of the dialog box giving the error and saved it. It's funny that I don't get this error at all when running the old Windows Messaging client, only when running Outlook. Here's my code:
* SendMail Routine

WAIT WINDOW NOWAIT NOCLEAR "Please Wait... Sending Electronic Change Order Files"

* Send mail using MSMAPI
* Add instances of the MSMAPI.MAPISession and MSMAPI.MAPIMessages OLE controls to this form.
ThisForm.NewObject("Session1","MAPISess","MAPIClas.vcx")
ThisForm.NewObject("Message1","MAPIMsgs","MAPIClas.vcx")

* Call the signon method of the MAPISession control. If the user is not
* logged on to mail, this will prompt the user to logon. This also sets
* the SessionID property for the MAPIsession control.
ThisForm.Session1.SignOn

* Set the SessionID of the MAPIMessage control
* to the SessionID of the MAPISession control, which was just obtained.
ThisForm.Message1.SessionID = ThisForm.Session1.SessionID

* Start an e-mail message
ThisForm.Message1.Compose

* Set the Subject line and Message text
ThisForm.Message1.MsgSubject = "Change Order " + Ord_Ma(2)
ThisForm.Message1.MsgNoteText = "Electronic Change Order Text file for Order Number: " + Ord_Ma(2)

* Increment the Recipient index
ThisForm.Message1.RecipIndex = 0

* Keep track of how many times you loop thru.
* Should loop thru 1 time for mWhoGets = "P" and
* should loop thru an additional time for mWhoGets = "C" "E" or "W"
STORE 0 TO mSendCounter

	SET FILTER TO Members.Flag = mWhoGets
	SCAN
		* Attach the proper .txt file
		IF mWhoGets = "P"
			ThisForm.Message1.AttachmentPathname = "ChOPrice.txt"
		ELSE
			ThisForm.Message1.AttachmentPathname = "ChgOrder.txt"
		ENDIF
		* Get figures for Calculating AttachmentPosition
		mMsgNoteTextLength = "Electronic Change Order Text file for Order Number: " + Ord_Ma(2)
		mMsgNoteTextLength = LEN(mMsgNoteTextLength)
		ThisForm.Message1.AttachmentPosition = (mMsgNoteTextLength - 1) && Count starts from position 0
		* Set the Recipient Name
		ThisForm.Message1.RecipDisplayName = ALLTRIM(Name)
		* Resolve the Recipient Name
		ThisForm.Message1.ResolveName
		* Sends the e-mail message.
		ThisForm.Message1.Send
	ENDSCAN
	SET FILTER TO && Reset FILTER TO filter nothing.

* Remove instances of the MSMAPI.MAPISession and MSMAPI.MAPIMessages OLE controls from this form.
ThisForm.RemoveObject("Session1","MAPISess","MAPI.vcx")
ThisForm.RemoveObject("Message1","MAPIMsgs","MAPI.vcx")

* END of SendMail routine.
Chuck Henry
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform