Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Outlook Automation
Message
 
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01331517
Message ID:
01331523
Views:
29
Try with '=' prefix
= loitem.Move(loSpace.Folders(OL_pst).Folders(OL_fldr))
If it doesn't help, try to get a folder reference first
loFolder = loSpace.Folders(OL_pst).Folders(OL_fldr)
= loitem.Move(loFolder)
BTW, it's redundant to compare logical values with .T. or .F.. They are already logical.
IF pst_chk == .F. OR fldr_chk == .F.
* Should be
IF NOT pst_chk OR NOT fldr_chk

* And so on
>I am creating an application to act similar to the Outlook Rules Wizard but I am having a problem moving the e-mail items from the inbox to the selected personal folder. Its very puzzling because when I step through the code everything works fine but when ran normally I get a "Parameter Not Optional Error" when it hits the first move command. I've checked both in debugging and displaying in a message box the values of the folders I'm trying to move the email to and the correct values are displayed every time but as I said before it only works in debug. I provided some sample code that shows how I'm attempting to move the e-mails and any help is greatly appreciated.
>
>Error occurs when one of these lines executes.
>loitem.Move(loSpace.Folders(OL_pst).Folders(OL_fldr))
>
>
>Code sample makes use of the Outlook Redemption dll.
>
>
>
>
>&& ==== INITIATE OUTLOOK APPLICATION OBJECTS ===== &&
>loApp    = CREATEOBJECT("Outlook.Application")
>loSpace  = loApp.GetNameSpace("MAPI")
>objSMail = CREATEOBJECT("Redemption.SafeMailItem")
>&& ==== INITIATE OUTLOOK APPLICATION OBJECTS ===== &&
>
>
>&& ====== SORT INBOX ITEMS TO ASSIGNED FOLDERS ======= &&
>SELECT C_RULES
>SCAN ALL
>	OL_rule   = UPPER(ALLTRIM(C_RULES.RULE_NM))
>	OL_pst    = UPPER(ALLTRIM(C_RULES.RULE_PST))
>	OL_fldr   = UPPER(ALLTRIM(C_RULES.RULE_FLDR))
>	OL_srch   = UPPER(ALLTRIM(C_RULES.RULE_SRCH))
>	pst_chk   = .F.
>	fldr_chk  = .F.
>	
>
>	&& ====== VERIFY OUTLOOK PST FILE & FOLDER EXISTS ======= &&
>	pst_cnt = loSpace.Folders.Count
>	FOR xx=1 TO pst_cnt
>		cur_pst = UPPER(ALLTRIM(loSpace.Folders(xx).Name))
>	
>		IF UPPER(ALLTRIM(cur_pst)) == OL_pst
>			pst_chk = .T.
>			
>			loFolders = loSpace.Folders(xx)
>
>			fldr_cnt = loFolders.Folders.Count
>			FOR zz=1 TO fldr_cnt
>		    	cur_fldr = UPPER(ALLTRIM(loFolders.Folders(zz).Name))
>
>				IF UPPER(ALLTRIM(cur_fldr)) == OL_fldr
>					fldr_chk = .T.
>					EXIT
>				ENDIF
>			ENDFOR
>			
>			EXIT
>		ENDIF
>	ENDFOR
>	&& ====== VERIFY OUTLOOK PST FILE & FOLDER EXISTS ======= &&
>
>
>	&& ==== LOOP IF FOLDER NOT FOUND ==== &&
>	IF pst_chk == .F. OR fldr_chk == .F.
>		LOOP
>	ENDIF
>	&& ==== LOOP IF FOLDER NOT FOUND ==== &&
>	
>					
>	loInbox = loSpace.GetDefaultFolder(6)
>
>	oItems = loSpace.GetDefaultFolder(6).Items
>
>
>	&& ==== MOVE E-MAIL ACCORDING TO RULE CONDITION ==== &&	
>	FOR EACH loItem IN oItems
>		
>		DO CASE
>			CASE C_RULES.OPT_SNDER == .T.
>				&& ==== GET SENDER ADDRESS ==== &&
>				PR_SENDER_ADDRTYPE = "&HC1E001E"
>		  		PR_EMAIL = "&H39FE001E"
>				
>				objSMail.Item = loItem
>				strType = objSMail.Fields(PR_SENDER_ADDRTYPE)
>				objSenderAE = objSMail.Sender
>				If !ISNULL(objSenderAE)
>					If UPPER(ALLTRIM(strType)) == "SMTP"
>					  	sndr_addr = objSenderAE.Address
>					ELSE
>						IF UPPER(ALLTRIM(strType)) == "EX"
>						  	sndr_addr = objSenderAE.Fields(PR_EMAIL)
>						ENDIF
>					ENDIF 	
>				ENDIF
>				&& ==== GET SENDER ADDRESS ==== &&
>				
>				IF UPPER(ALLTRIM(C_RULES.RULE_SRCH)) $ UPPER(ALLTRIM(sndr_addr))
>					loitem.Move(loSpace.Folders(OL_pst).Folders(OL_fldr))
>				ENDIF
>				
>			CASE C_RULES.OPT_SUBJCT == .T.
>				IF UPPER(ALLTRIM(C_RULES.RULE_SRCH)) $ UPPER(ALLTRIM(loitem.Subject))
>					loitem.Move(loSpace.Folders(OL_pst).Folders(OL_fldr))
>				ENDIF
>			
>			CASE C_RULES.OPT_BODY == .T.
>				IF UPPER(ALLTRIM(C_RULES.RULE_SRCH)) $ UPPER(ALLTRIM(loitem.Body))
>					loitem.Move(loSpace.Folders(OL_pst).Folders(OL_fldr))
>				ENDIF
>				
>			OTHERWISE
>				&& DEFAULT
>		ENDCASE
>		
>	NEXT
>	&& ==== MOVE E-MAIL ACCORDING TO RULE CONDITION ==== &&
>	
>ENDSCAN
>&& ====== SORT INBOX ITEMS TO ASSIGNED FOLDERS ======= &&
>
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform