Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to send specific Outlook items
Message
De
30/07/2009 10:01:16
Robert Pinchar
Io Technologies, Inc.
Wisconsin, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
How to send specific Outlook items
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Application:
Desktop
Divers
Thread ID:
01415508
Message ID:
01415508
Vues:
111
Hello,

We have an application which sends appointments through Outlook (we are using Redemption). How can we force sending only the appointments we want to send and not everything which is already in the Outbox. Below is the code we are using:
IF llContinue
		
			llRedemption = .F.

			IF ZCHECKSERVER("Redemption.SafeMailItem")
				llRedemption = .T.
			ELSE
				IF ISFILETHERE( ADDBS(GETENV("SystemRoot"))+"system32\" + "Redemption.dll" )
					lcDlL = ADDBS(GETENV("SystemRoot"))+"system32\" + "Redemption.dll"
					RUN regsvr32.EXE /s &lcDlL

					llRedemption = ZCHECKSERVER("Redemption.SafeAppointmentItem")
				ELSE
					llRedemption = .F.
				ENDIF

			ENDIF

		
			loOutLook=CREATEOBJECT("outlook.application")
			loNameSpace = loOutLook.GetNameSpace('MAPI')
			loNameSpace.Logon()
			lnSentDate=VFPDateToClarion(DATE())
			
			SELECT cAppointments
			SCAN FOR lSendAppt
				IF ( llRedemption )

					loAppt = CREATEOBJECT('Redemption.SafeAppointmentItem') && open redemption
					loAppt.ITEM = loOutLook.createitem(1) && create safe item object

				ELSE
					loAppt=loOutLook.createitem(1)
				ENDIF
				loAppt.Start = cAppointments.tApptStart
				loAppt.End = cAppointments.tApptEnd
				loAppt.AllDayEvent=(cAppointments.tApptStart=TTOD(cAppointments.tApptStart)) && Time wasn't specified

				loAppt.MeetingStatus = 1 && olMeeting 
				loAppt.Subject=ALLTRIM(cAppointments.Service_Code)+": "+ALLTRIM(cAppointments.cTech1)+" Assist: "+IIF(EMPTY(cAppointments.cTech2),"none",ALLTRIM(cAppointments.cTech2))+" - "+ALLTRIM(cAppointments.cName)
				TEXT TO lcBody TEXTMERGE NOSHOW PRETEXT 1+2
				
					Scheduled by: <<cAppointments.cScheduler>>
				
					When: <<IIF(loAppt.AllDayEvent,TRANSFORM(TTOD(cAppointments.tApptStart),"@YL"),TRANSFORM(cAppointments.tApptStart,"@YL")+"-"+LTRIM(TTOC(cAppointments.tApptEnd,2),1,"0"))>> (GMT-06:00) Central Time (US & Canada).

					ACCOUNT NUMBER: <<ALLTRIM(cAppointments.ServiceNum)+IIF(EMPTY(cAppointments.CodeWord),""," ("+cAppointments.CodeWord+")")>>
					 
					CUSTOMER NAME: <<cAppointments.cName>>

					ADDRESS: <<ALLTRIM(cAppointments.Address1)+IIF(EMPTY(cAppointments.Address2),"",", "+ALLTRIM(cAppointments.Address2))+", "+ALLTRIM(cAppointments.Town)+", "+ALLTRIM(cAppointments.State)+" "+ALLTRIM(cAppointments.Zip)>>

					PROBLEM REPORT: <<cAppointments.Problem1>>
				ENDTEXT
				loAppt.Body=lcBody
				
				SELECT Email_Recipients
				SCAN FOR lActive
					loPerson = loAppt.Recipients.Add(ALLTRIM(Email_Recipients.cEmailAddr))
					loPerson.Type = 1
					loPerson.Resolve()
				ENDSCAN
				
				loAppt.Send()
				loAppt.Save()

				* Set Unused3 to the date so we know not to grab it again
				SQLEXEC(lnHandle,"UPDATE AppDet SET Unused3=?lnSentDate WHERE SysID=?cAppointments.SysID")
			ENDSCAN
			
			loFolder = loNameSpace.GetDefaultfolder(4) && Go to Outbox, folder 4
			ltSendStartTime=DATETIME()
			DO WHILE loFolder.Items.Count>0 AND DATETIME()-ltSendStartTime<10
				* Force delivery
				FOR lnIndex=1 TO loNameSpace.SyncObjects.Count
					loNameSpace.SyncObjects.Item(lnIndex).Start()
				ENDFOR
			ENDDO
			
			MESSAGEBOX("Appointments have been sent.",0+64,"Appointments sent",60000)
			
			* Not sure if we need to do a loOutlook.Quit() here
			* UPDATE - when testing, Outlook appears to close itself, and Quit() is not necessary
		ENDIF
The client complains that when we have a single appointment for 11 recipients, the system is trying to send about 409 tasks. Eventually, the user is prompted for the name/password and they have to cancel out of the program. The Outlook is configured to use gmail account.

Redemption does not appear to be working. Warnings are issued regarding allowing access to Outlook. Also, as the email is being sent, 713 tasks of receiving and sending take place. After which, 300 more tasks of receiving/sending must occur before the email is sent.

Do you see a problem in the code or do you know why would Outlook generate so many tasks to send one appointment to 13 recipients?

Thank you,
Bob
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform