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.UserName = "Microsoft Outlook" && You can call the profile to use, if desired. 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 * There should always be a record for Glenda Burger in Members.dbf with Flag="P" [(P)rice Quotes] SELECT Members LOCATE FOR Flag = "P" IF EOF() = .T. INSERT INTO Members ; (Name, ; Address, ; Flag) ; VALUES ; ("GLENDA BURGER", ; "Glenda Burger", ; "P") ENDIF STORE "P" TO mWhoGets * 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 DO WHILE mWhoGets <> "Done" LOCATE FOR Flag = mWhoGets IF EOF() = .T. MESSAGEBOX("You have no recipients set up to receive" + CHR(13) + ; "order changes flagged as '" + mWhoGets + ".'" + CHR(13) + ; CHR(13) + ; "Go into the Change Order Recipients screen" + CHR(13) + ; "and add recipients as necessary." + CHR(13) + ; CHR(13) + ; "This Change Order transmission will now be cancelled.", ; 0+16+0, ; "Error: No Recipients found for '" + mWhoGets + ".'") RETURN ENDIF SET FILTER TO Members.Flag = mWhoGets SCAN * Attach the proper .txt file ThisForm.Message1.AttachmentPathname = SYS(5) + CURDIR() + ; IIF(mWhoGets = "P", "ChOPrice.txt", "ChgOrder.txt") * 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 IF Ord_Ma(8) <> "No Change" && No Warehouse Changes STORE "W" TO mWhoGets ELSE IF Ord_Ma(7) = "EASTLAND" STORE "E" TO mWhoGets ELSE IF Ord_Ma(7) = "CORDELE" STORE "C" TO mWhoGets ENDIF ENDIF ENDIF mSendCounter = mSendCounter + 1 IF mSendCounter = 2 STORE "Done" TO mWhoGets ENDIF SET FILTER TO && Reset FILTER TO filter nothing. ENDDO * 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")