*--------------------------------------------------------------------------------------------------------------------------------------------------------
* (EN) AUTOGENERATED - ATTENTION!! - NOT INTENDED FOR EXECUTION!! USE ONLY FOR MERGING CHANGES AND STORING WITH SCM TOOLS!!
*--------------------------------------------------------------------------------------------------------------------------------------------------------
*< FOXBIN2PRG: Version="1.21" SourceFile="pr_sendmail2.scx" CPID="1252" /> (Solo para binarios VFP 9 / Only for VFP 9 binaries)
*
*
DEFINE CLASS dataenvironment AS dataenvironment 
 	*< CLASSDATA: Baseclass="dataenvironment" Timestamp="" Scale="" Uniqueid="" ClassIcon="1" />

	*<PropValue>
		DataSource = .NULL.
		Height = 200
		Left = 316
		Name = "Dataenvironment"
		Top = 188
		Width = 331
	*</PropValue>

ENDDEFINE

DEFINE CLASS frmsendmail2 AS form 
 	*< CLASSDATA: Baseclass="form" Timestamp="" Scale="" Uniqueid="" />

	*-- OBJECTDATA items order determines ZOrder / El orden de los items OBJECTDATA determina el ZOrder 
	*< OBJECTDATA: ObjPath="Chtmleditor1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="txtDestination" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="TxtSubject" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkPriority" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="chkReceipt" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmbAttach" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdAttachment" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblTo" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="lblSubject" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdSend" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdCancel" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="Command1" UniqueID="" Timestamp="" />
	*< OBJECTDATA: ObjPath="cmdSendFax" UniqueID="" Timestamp="" />

	*<DefinedPropArrayMethod>
		*m: removeattachment
		*m: setlanguage
		*p: ctempfile
		*p: _memberdata		&& XML Metadata for customizable properties
		*p: _origautoyield
		*p: _origsys2333
	*</DefinedPropArrayMethod>

	*<PropValue>
		AllowOutput = .F.
		AlwaysOnTop = .T.
		AutoCenter = .T.
		BorderStyle = 3
		Caption = "Send report to email"
		Closable = .F.
		ctempfile = 
		DataSession = 1
		Desktop = .T.
		DoCreate = .T.
		Height = 492
		MaxButton = .T.
		MinHeight = 250
		MinWidth = 580
		Name = "frmSendMail2"
		ShowTips = .T.
		ShowWindow = 1
		Width = 690
		WindowType = 1
		_memberdata = <VFPData>
			<memberdata name="removeattachment" display="RemoveAttachment"/>
			<memberdata name="_origautoyield" display="_OrigAutoYield"/>
			<memberdata name="_origsys2333" display="_OrigSYS2333"/>
		</VFPData>
		_origautoyield = .F.
		_origsys2333 = .F.
	*</PropValue>

	ADD OBJECT 'chkPriority' AS checkbox WITH ;
		Alignment = 0, ;
		Caption = "Priority", ;
		Height = 13, ;
		Left = 537, ;
		Name = "chkPriority", ;
		TabIndex = 9, ;
		Top = 108, ;
		Value = .F., ;
		Visible = .T., ;
		Width = 148
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'chkReceipt' AS checkbox WITH ;
		Alignment = 0, ;
		Caption = "Read receipt", ;
		Height = 13, ;
		Left = 537, ;
		Name = "chkReceipt", ;
		TabIndex = 11, ;
		Top = 84, ;
		Value = .F., ;
		Visible = .T., ;
		Width = 148
		*< END OBJECT: BaseClass="checkbox" />

	ADD OBJECT 'Chtmleditor1' AS chtmleditor WITH ;
		Anchor = 15, ;
		BorderWidth = 0, ;
		Height = 365, ;
		Left = 1, ;
		Name = "Chtmleditor1", ;
		TabIndex = 3, ;
		Top = 84, ;
		Width = 655, ;
		oIE.Height = 120, ;
		oIE.Left = 0, ;
		oIE.Name = "oIE", ;
		oIE.TabIndex = 1, ;
		oIE.Top = 48, ;
		oIE.Width = 132, ;
		tgBold.Alignment = 0, ;
		tgBold.Name = "tgBold", ;
		tgBold.TabIndex = 23, ;
		tgItalic.Alignment = 0, ;
		tgItalic.Name = "tgItalic", ;
		tgItalic.TabIndex = 24, ;
		tgUnderline.Alignment = 0, ;
		tgUnderline.Name = "tgUnderline", ;
		tgUnderline.TabIndex = 25, ;
		tgLeft.Alignment = 0, ;
		tgLeft.Name = "tgLeft", ;
		tgLeft.TabIndex = 10, ;
		tgCenter.Alignment = 0, ;
		tgCenter.Name = "tgCenter", ;
		tgCenter.TabIndex = 11, ;
		tgRight.Alignment = 0, ;
		tgRight.Name = "tgRight", ;
		tgRight.TabIndex = 12, ;
		btnForeColor.Name = "btnForeColor", ;
		btnForeColor.TabIndex = 26, ;
		btnBackColor.Name = "btnBackColor", ;
		btnBackColor.TabIndex = 27, ;
		cmbFontName.Height = 23, ;
		cmbFontName.Left = 0, ;
		cmbFontName.Name = "cmbFontName", ;
		cmbFontName.TabIndex = 21, ;
		cmbFontName.Top = 24, ;
		cmbFontName.Width = 154, ;
		cmbFontSize.Alignment = 2, ;
		cmbFontSize.Height = 23, ;
		cmbFontSize.Left = 159, ;
		cmbFontSize.Name = "cmbFontSize", ;
		cmbFontSize.TabIndex = 22, ;
		cmbFontSize.Top = 24, ;
		cmbFontSize.Width = 47, ;
		tgIncrease.Alignment = 0, ;
		tgIncrease.Name = "tgIncrease", ;
		tgIncrease.TabIndex = 16, ;
		tgDecrease.Alignment = 0, ;
		tgDecrease.Name = "tgDecrease", ;
		tgDecrease.TabIndex = 15, ;
		tgBullet.Alignment = 0, ;
		tgBullet.Name = "tgBullet", ;
		tgBullet.TabIndex = 14, ;
		tgNumbers.Alignment = 0, ;
		tgNumbers.Name = "tgNumbers", ;
		tgNumbers.TabIndex = 29, ;
		cmdHyperlink.Name = "cmdHyperlink", ;
		cmdHyperlink.TabIndex = 18, ;
		cmdPicture.Name = "cmdPicture", ;
		cmdPicture.TabIndex = 19, ;
		Label1.Left = 453, ;
		Label1.Name = "Label1", ;
		Label1.TabIndex = 28, ;
		Label1.Top = 28, ;
		Label1.Visible = .F., ;
		tgJustify.Alignment = 0, ;
		tgJustify.Name = "tgJustify", ;
		tgJustify.TabIndex = 13, ;
		cmdOpen.Name = "cmdOpen", ;
		cmdSave.cpropertyname = , ;
		cmdSave.Name = "cmdSave", ;
		cmdNew.Name = "cmdNew", ;
		cmdCut.cpropertyname = Cut, ;
		cmdCut.Name = "cmdCut", ;
		cmdCopy.cpropertyname = Copy, ;
		cmdCopy.Name = "cmdCopy", ;
		cmdPaste.cpropertyname = Paste, ;
		cmdPaste.Name = "cmdPaste", ;
		cmdUndo.cpropertyname = Undo, ;
		cmdUndo.Name = "cmdUndo", ;
		cmdRedo.cpropertyname = Redo, ;
		cmdRedo.Name = "cmdRedo", ;
		tgLine.Alignment = 0, ;
		tgLine.Name = "tgLine", ;
		tgLine.TabIndex = 17, ;
		tgCLean.Alignment = 0, ;
		tgCLean.Left = 503, ;
		tgCLean.Name = "tgCLean", ;
		tgCLean.TabIndex = 20, ;
		tgCLean.Top = 0
		*< END OBJECT: ClassLib="pr_htmledit.vcx" BaseClass="container" />

	ADD OBJECT 'cmbAttach' AS combobox WITH ;
		ColumnCount = 2, ;
		ColumnLines = .F., ;
		ColumnWidths = "160,0", ;
		FontSize = 8, ;
		Height = 24, ;
		Left = 537, ;
		Name = "cmbAttach", ;
		Style = 2, ;
		TabIndex = 8, ;
		Top = 48, ;
		Width = 141
		*< END OBJECT: BaseClass="combobox" />

	ADD OBJECT 'cmdAttachment' AS commandbutton WITH ;
		Caption = "", ;
		Height = 23, ;
		Left = 504, ;
		Name = "cmdAttachment", ;
		Picture = images\pr_attach.bmp, ;
		SpecialEffect = 2, ;
		TabIndex = 7, ;
		Top = 48, ;
		Width = 23
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmdCancel' AS commandbutton WITH ;
		Anchor = 12, ;
		Cancel = .T., ;
		Caption = "Cancel", ;
		Height = 27, ;
		Left = 592, ;
		Name = "cmdCancel", ;
		TabIndex = 5, ;
		Top = 456, ;
		Width = 84
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmdSend' AS commandbutton WITH ;
		Anchor = 12, ;
		Caption = "Send", ;
		Height = 27, ;
		Left = 495, ;
		Name = "cmdSend", ;
		Picture = images\pr_sendmessage.bmp, ;
		PicturePosition = 0, ;
		TabIndex = 4, ;
		Top = 456, ;
		Width = 84
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'cmdSendFax' AS commandbutton WITH ;
		Anchor = 12, ;
		Caption = "Fax", ;
		Height = 27, ;
		Left = 398, ;
		Name = "cmdSendFax", ;
		Picture = images\pr_fax.bmp, ;
		PicturePosition = 0, ;
		TabIndex = 4, ;
		Top = 456, ;
		Visible = .F., ;
		Width = 84
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'Command1' AS commandbutton WITH ;
		Caption = "", ;
		Height = 23, ;
		Left = 5, ;
		Name = "Command1", ;
		Picture = images\pr_adress.bmp, ;
		SpecialEffect = 2, ;
		TabIndex = 6, ;
		TabStop = .F., ;
		Top = 12, ;
		Width = 23
		*< END OBJECT: BaseClass="commandbutton" />

	ADD OBJECT 'lblSubject' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "Subject:", ;
		Height = 17, ;
		Left = 8, ;
		Name = "lblSubject", ;
		TabIndex = 12, ;
		Top = 50, ;
		Width = 46
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'lblTo' AS label WITH ;
		AutoSize = .T., ;
		BackStyle = 0, ;
		Caption = "To:", ;
		Height = 17, ;
		Left = 29, ;
		Name = "lblTo", ;
		TabIndex = 10, ;
		Top = 14, ;
		Width = 19
		*< END OBJECT: BaseClass="label" />

	ADD OBJECT 'txtDestination' AS textbox WITH ;
		AutoComplete = 2, ;
		AutoCompTable = "FoxyPreviewer_Emails", ;
		Format = "K", ;
		Height = 23, ;
		Left = 110, ;
		MaxLength = 255, ;
		Name = "txtDestination", ;
		TabIndex = 1, ;
		Top = 12, ;
		Width = 386
		*< END OBJECT: BaseClass="textbox" />

	ADD OBJECT 'TxtSubject' AS textbox WITH ;
		Format = "K", ;
		Height = 23, ;
		Left = 110, ;
		Name = "TxtSubject", ;
		TabIndex = 2, ;
		Top = 48, ;
		Width = 386
		*< END OBJECT: BaseClass="textbox" />
	
	PROCEDURE Activate
		IF EMPTY(This.Comment)
			This.Width = This.Width + 1
			This.Comment = "Started"
		ENDIF
		
	ENDPROC

	PROCEDURE Init
		LPARAMETERS tcFile
		
		* Thisform.lblAttachment.Caption = JUSTFNAME(tcFile)
		IF NOT EMPTY(tcFile)
			WITH Thisform.CmbAttach as ComboBox 
				.AddItem(JUSTFNAME(tcFile))
				.List(.NewIndex, 2) = tcFile
				.ListIndex = 1
				.Refresh()
			ENDWITH
		ENDIF
		
		
		LOCAL lcAttach, n, lcFile
		lcAttach = _goFP.cAttachments
		
		IF NOT EMPTY(lcAttach)
		
			lcAttach = CHRTRAN(lcAttach, ";", ",")
		
			FOR m.n = 1 TO GETWORDCOUNT(lcAttach, ",")
		
				lcFile = GETWORDNUM(lcAttach, m.n, ",")
				IF NOT FILE(lcFile)
					LOOP
				ENDIF 
								
				WITH Thisform.CmbAttach as ComboBox 
					.AddItem(JUSTFNAME(lcFile))
					.List(.NewIndex, 2) = lcFile
					.ListIndex = 1
					.Refresh()
				ENDWITH
		
			ENDFOR
		
		ENDIF 
		
		Thisform.AddProperty("lCancelled", .F.)
		
		TRY
			This.Icon = _goFP.cFormIcon
		CATCH
		ENDTRY
		
		TRY
			WITH _goFP
				This.txtDestination.Value = .cEmailTo
				This.txtSubject.Value     = .cEmailSubject
				* This.edtBody.Value        =	.cEmailBody
				This.chkPriority.Value    = .lPriority
				This.chkReceipt.Value     = .lReadReceipt
		
				This.Caption              = .GetLoc("SENDEMAIL")
				This.CmdCancel.Caption    = .GetLoc("CANCEL")
				This.CmdSend.Caption      = .GetLoc("SEND")
				This.lblSubject.Caption   = .GetLoc("SUBJECT")
				This.lblTo.Caption        = .GetLoc("TO")
		
				* Determine if the fax button will be shown
				IF NOT EMPTY(.cFAXprg)
					Thisform.cmdSendFax.Visible = .T.
				ENDIF
		
		
				TRY 
					IF NOT EMPTY(_goFP.cEmailBody) OR NOT EMPTY(_goFP.cEmailBodyFile)
						LOCAL lcHTMLFile
		
						IF NOT EMPTY(_goFP.cEmailBody)
							lcHTMLfile = FORCEEXT(ADDBS(SYS(2023))+SYS(2015),"htm")
							STRTOFILE(_goFP.cEmailBody, lcHTMLFile)
							Thisform.cTempFile = lcHTMLFile
							INKEY(.1)
						ELSE 
							lcHTMLfile = _goFP.cEmailBodyFile
						ENDIF 
		
						IF FILE(lcHTMLfile)
							WITH Thisform.Chtmleditor1.oIE
								.Navigate(lcHTMLFile)
								DO WHILE .ReadyState != 4
									DOEVENTS
								ENDDO
								.Document.Body.contentEditable = .T.
							ENDWITH
		
						    IF lcHTMLfile ==_goFP.cEmailBodyFile && Whithout this the "cEmailBodyFile" will be always deleted!!... by Nick Porfyris [20101213]...
							ELSE
								DELETE FILE (lcHTMLFile)
							ENDIF
						ENDIF
					ENDIF
				CATCH
					MESSAGEBOX("Could not load the HTML body file", 48, "Error loading HTML")
				ENDTRY
		
			ENDWITH
		CATCH
		ENDTRY
		
		This.SetLanguage()
		RETURN
		
		
		*!*	XP Style WebBrowser Control 
		*!*	I'm sure there is more then me that been looking for a way to get the XP style in the WebBrowser Control.
		*!*	To enable the XP style in your web pages that you load in your WebBrowser Control put the following line in your head tags:
		*!*	Code:
		*!*	<META HTTP-EQUIV='MSThemeCompatible' CONTENT='Yes'>
		
		
		
		*!*	* Testing code
		
		*!*	TEXT TO lcHTML NOSHOW 
		*!*	<HTML><HEAD>
		*!*	<STYLE></STYLE>
		*!*	</HEAD>
		*!*	<BODY bgColor=#ffffff>
		*!*	<FONT face=Verdana size=2>
		*!*	<<lcLogoImg>>
		*!*	To<BR></FONT>
		
		*!*	<<tcHTMLbody>>
		
		*!*	<BR>
		*!*	<BR>
		*!*	<FONT face=Verdana size=2>Sincerely</FONT>
		*!*	<P></P>
		*!*	<BR>
		*!*	<HR><STRONG>
		*!*	<FONT face=Verdana size=1>FoxyPreviewer team.</FONT></STRONG>
		*!*	<FONT face=Arial color=black size=1><BR>
		*!*	<FONT face=Verdana>1818 Super Street&nbsp; -&nbsp; Your Home<BR>05432-030 &nbsp;- &nbsp;Your City&nbsp;- &nbsp;XX</FONT><BR>
		*!*	<FONT face=Wingdings color=black size=2>(</FONT><STRONG> </STRONG>
		*!*	<FONT face=Verdana>Phone: 1 11 -&nbsp;3322.2233 <BR></FONT>
		*!*	<FONT face=Wingdings color=black size=2>(</FONT> 
		*!*	<FONT face=Verdana>Fax:&nbsp;&nbsp; 2 11 - 3366.6656<BR></FONT>
		*!*	<FONT face=Wingdings color=black size=2>*</FONT>
		*!*	<A href="mailto:contact@mycompany.com"><FONT face=Verdana>contact@mycompany.com</FONT></A> </FONT>
		*!*	<BR>
		*!*	</HTML>
		*!*	ENDTEXT
		
		
		
		*!*		SET TEXTMERGE ON
		*!*		lcHTML = TEXTMERGE(lcHTML,.T.,"<<",">>")
		*!*		
		*!*		lcFile = FORCEEXT(ADDBS(SYS(2023))+SYS(2015),"htm")
		*!*		Thisform.cTempFile = lcFile
		*!*		STRTOFILE(lcHTML, lcFile)
		
		*!*		WITH Thisform.Chtmleditor1.oIE
		*!*			.Navigate(lcFile)
		*!*			DO WHILE .ReadyState != 4
		*!*				DOEVENTS
		*!*			ENDDO
		*!*			.Document.Body.contentEditable = .T.
		*!*		ENDWITH
		
		
		* Article with all the EXECWB commands available
		* http://delphicikk.atw.hu/listaz.php?id=1391&oldal=41
	ENDPROC

	PROCEDURE Load
		SET TALK OFF
		SET CONSOLE OFF 
		
		
		*!*	* Adjust some properties to make sure the WebBrowser active-X will work as desired
		*!*	* http://www.tek-tips.com/viewthread.cfm?qid=1204873&page=168
		
		*!*	This._OrigAutoYield = _VFP.AutoYield
		*!*	This._OrigSYS2333   = VAL(SYS(2333, 2))
		
		*!*	_VFP.AutoYield = .F.
		*!*	SYS(2333, 1)
	ENDPROC

	PROCEDURE removeattachment
		LOCAL lnOption, lcCancel, lcRemove
		lnOption = 0
		
		IF VARTYPE(_goFP) = "O"
			lcCancel = _goFP.GetLoc("CANCEL")
			lcRemove = _goFP.GetLoc("REMOVEFILE")
		ELSE
			lcCancel = "Cancel"
			lcRemove = "Remove file"
		ENDIF 
		
		
		LOCAL loList as ComboBox
		loList = Thisform.CmbAttach 
		
		DEFINE POPUP MyShortCut SHORTCUT RELATIVE FROM MROW(),MCOL()
		DEFINE BAR 1 OF MyShortCut PROMPT lcRemove + ": " + ;
			loList.ListItem(loList.ListIndex)
		DEFINE BAR 2 OF MyShortCut PROMPT lcCancel
		
		ON SELECTION POPUP MyShortCut lnOption = BAR()
		ACTIVATE POPUP MyShortCut
		
		IF lnOption = 1 && Remove file
			loList.RemoveListItem(loList.ListItemId)
			loList.ListIndex = 1
		ENDIF
	ENDPROC

	PROCEDURE setlanguage
		LOCAL loExc as Exception
		TRY
		
			IF VARTYPE(_goFP) = "O"
		
			WITH This
				.lblTo.Caption                        = _goFP.GetLoc("TO")
				.lblSubject.Caption                   = _goFP.GetLoc("SUBJECT")
		
				.cmdAttachment.ToolTipText            = _goFP.GetLoc("ATTACHMENT")
				.cmbAttach.ToolTipText                = _goFP.GetLoc("ATTACHMENT")
		
				.chkPriority.Caption    = _goFP.GetLoc("PRIORITY")
				.chkReceipt.Caption     = _goFP.GetLoc("RECEIPT")
		
				.chtmleditor1.tgBold.ToolTipText      = _goFP.GetLoc("BOLD")
				.chtmleditor1.tgBold.Caption          = LEFT(_goFP.GetLoc("BOLD"),1)
				.chtmleditor1.tgItalic.ToolTipText    = _goFP.GetLoc("ITALIC")
				.chtmleditor1.tgItalic.Caption        = LEFT(_goFP.GetLoc("ITALIC"),1)
				.chtmleditor1.tgUnderline.ToolTipText = _goFP.GetLoc("UNDERLINE")
				.chtmleditor1.tgUnderline.Caption     = LEFT(_goFP.GetLoc("UNDERLINE"),1)
		
				.chtmleditor1.tgLeft.ToolTipText      = _goFP.GetLoc("ALIGNLEFT")
				.chtmleditor1.tgCenter.ToolTipText    = _goFP.GetLoc("ALIGNCENTE")
				.chtmleditor1.tgRight.ToolTipText     = _goFP.GetLoc("ALIGNRIGHT")
				.chtmleditor1.tgJustify.ToolTipText   = _goFP.GetLoc("ALIGNJUSTI")
		
				.chtmleditor1.cmdHyperlink .ToolTipText = _goFP.GetLoc("HYPERLINK")
				.chtmleditor1.cmdPicture.ToolTipText  = _goFP.GetLoc("ADDPICTURE")
				.chtmleditor1.tgDecrease.ToolTipText  = _goFP.GetLoc("INDENTREDU")
				.chtmleditor1.tgIncrease.ToolTipText  = _goFP.GetLoc("INDENTINCR")
		
				.chtmleditor1.tgLine.ToolTipText      = _goFP.GetLoc("HORIZBAR")
				.chtmleditor1.tgClean.ToolTipText     = _goFP.GetLoc("CLEANFORMT")
		
				.chtmleditor1.tgBullet.ToolTipText    = _goFP.GetLoc("LISTBULLET")
				.chtmleditor1.tgNumbers.ToolTipText   = _goFP.GetLoc("LISTNUMBER")
		
				.chtmleditor1.cmdCopy.ToolTipText      = _goFP.GetLoc("COPY")
				.chtmleditor1.cmdCut.ToolTipText       = _goFP.GetLoc("CUT")
				.chtmleditor1.cmdPaste.ToolTipText     = _goFP.GetLoc("PASTE")
		
				.chtmleditor1.cmdOpen.ToolTipText      = _goFP.GetLoc("HTMLMODEL")
				.chtmleditor1.cmdSave.ToolTipText      = _goFP.GetLoc("SAVEASHTML")
				.chtmleditor1.cmdNew.ToolTipText       = _goFP.GetLoc("NEW")
		
				.chtmleditor1.cmdUndo.ToolTipText      = _goFP.GetLoc("UNDO")
				.chtmleditor1.cmdRedo.ToolTipText      = _goFP.GetLoc("REDO")
		
				.chtmleditor1.cmbFontName.ToolTipText = _goFP.GetLoc("FONTNAME")
				.chtmleditor1.cmbFontSize.ToolTipText = _goFP.GetLoc("FONTSIZE")
		
				.chtmleditor1.btnForeColor.ToolTipText = _goFP.GetLoc("FONTCOLOR")
				.chtmleditor1.btnBackColor.ToolTipText = _goFP.GetLoc("BACKCOLOR")
		
			ENDWITH
		
			ENDIF 
		
		CATCH TO loExc
			SET STEP ON
		ENDTRY
		
		RETURN
	ENDPROC

	PROCEDURE Unload
		*!*	* Restore ActiveX settings
		*!*	_VFP.AutoYield = This._OrigAutoYield
		*!*	SYS(2333, This._OrigSYS2333)
		
		IF NOT EMPTY(Thisform.cTempFile)
			TRY
				DELETE FILE (Thisform.cTempFile)
			CATCH
			ENDTRY
		ENDIF
		
		RETURN Thisform.lCancelled
	ENDPROC

	PROCEDURE Chtmleditor1.cmdSave.Click
		LOCAL lcHTML, lcFile, lcLocText
		
		IF VARTYPE(_goFP) = "O"
			lcLocText = _goFP.GetLoc("SAVEASHTML")
			lcFile = IIF(EMPTY(_goFP.cOutputPath), "", ADDBS(_goFP.cOutputPath))
			lcQuestion = _goFP.GetLoc("HTMLDEFA")
		ELSE
			lcLocText = "Save as HTML"
			lcFile = ""
			lcQuestion = "Make the saved file the default email body in the next sessions?"
		ENDIF
		
		lcFile = PUTFILE(lcLocText + "...", lcFile, "Htm;Html")
		IF NOT EMPTY(lcFile)
			lcHTML = "<HTML>" + Thisform.Chtmleditor1.oIE.Document.Body.OuterHTML + "</HTML>"
			lcHTML = STRTRAN(lcHTML, "contentEditable=true", "")
			STRTOFILE(lcHTML, lcFile)
		
			IF MESSAGEBOX(lcQuestion, 32 + 4, lcLocText) = 6 && Yes
				LOCAL lcAlias
				lcAlias  = SYS(2015)
		
				TRY
					USE ("FoxyPreviewer_Settings.dbf") IN 0 AGAIN SHARED ALIAS (lcAlias) && FP_Settings
					SELECT(lcAlias)
					LOCATE FOR ALLTRIM(UPPER(property)) == "CEMAILBODYFILE"     
					IF EOF()
						APPEND BLANK
						REPLACE Property WITH "cEmailBodyFile", ;
							cValue WITH lcFile ;
							IN (lcAlias)
					ELSE 
						REPLACE cValue WITH lcFile IN (lcAlias)
					ENDIF
				CATCH TO loExc
					MESSAGEBOX("Error updating the settings file" + CHR(13) + CHR(13) + ;
						TRANSFORM(loExc.ERRORNO) + " - " + loExc.MESSAGE + CHR(13) + ;
						"Line: " + TRANSFORM(loExc.LINENO) + " - " + loExc.LINECONTENTS, 16, "Error")
					SET STEP ON 
				ENDTRY
				USE IN SELECT(lcAlias)
			ENDIF
		ENDIF
	ENDPROC

	PROCEDURE Chtmleditor1.Resize
		This.width=this.parent.width
		This.height=this.parent.height - 115 &&  72
		*!*	*this.top=0
		*!*	*this.left=0
		This.oIE.Width  = This.Width - 2
		This.oIE.Height = This.Height - 60
		
	ENDPROC

	PROCEDURE cmbAttach.RightClick
		Thisform.RemoveAttachment()
	ENDPROC

	PROCEDURE cmdAttachment.Click
		LOCAL lcFile
		lcFile = GETFILE("", _goFP.GetLoc("ATTACHFILE"))
		* lcFile = GETFILE('', 'Anexar arquivo:', 'Anexar', 0, 'Anexar Arquivo')
		
		IF NOT EMPTY(lcFile)
			WITH Thisform.CmbAttach as ComboBox 
				.AddItem(JUSTFNAME(lcFile))
				.List(.NewIndex, 2) = lcFile
				.Refresh()
			ENDWITH
		
			Thisform.CmbAttach.Value = JUSTFNAME(lcFile)
		
			LOCAL n, lcTTip
			lcTtip = ""
			FOR m.n = 1 TO Thisform.cmbAttach.ListCount 
				lcTTip = lcTTip + Thisform.CmbAttach.List(m.n,1) + CHR(13)
			ENDFOR
			Thisform.cmbAttach.ToolTipText = lcTTip
		ENDIF
		
		RETURN
	ENDPROC

	PROCEDURE cmdAttachment.RightClick
		Thisform.RemoveAttachment()
	ENDPROC

	PROCEDURE cmdCancel.Click
		Thisform.lCancelled = .T.
		Thisform.Release()
	ENDPROC

	PROCEDURE cmdSend.Click
		Thisform.cHtmleditor1.lToggleUpdate = .F.
		
		LOCAL lcHTML, lcAttach, i
		
		IF VARTYPE(_goFP) <> "O"
			MESSAGEBOX("The email can't be sent because there is no FoxyPreviewer report active!", 16, "Error")
			RETURN
		ENDIF
		
		WITH _goFP
			.cEmailTo      = ALLTRIM(Thisform.txtDestination.Value)
			.cEmailSubject = ALLTRIM(Thisform.txtSubject.Value)
			lcHTML = "<HTML>" + Thisform.Chtmleditor1.oIE.Document.Body.OuterHTML + "</HTML>"
			lcHTML = STRTRAN(lcHTML, "contentEditable=true", "")
			.cEmailBody = lcHTML
		
			lcAttach = ""
			WITH Thisform.CmbAttach as ComboBox 
				FOR m.i = 1 TO .ListCount
					lcAttach = lcAttach + .List(m.i, 2) + ","
				ENDFOR
			ENDWITH
			lcAttach = LEFT(lcAttach, LEN(lcAttach) - 1)
			._cAttachment   = lcAttach
		
			.lReadReceipt  = Thisform.chkReceipt.Value
			.lPriority     = Thisform.chkPriority.Value
		
		ENDWITH 
		
		Thisform.Release()
		RETURN
	ENDPROC

	PROCEDURE cmdSendFax.Click
		Thisform.cHtmleditor1.lToggleUpdate = .F.
		
		LOCAL lcHTML, lcAttach, i
		
		IF VARTYPE(_goFP) <> "O"
			MESSAGEBOX("The email/fax can't be sent because there is no FoxyPreviewer report active!", 16, "Error")
			RETURN
		ENDIF
		
		WITH _goFP
			.cEmailTo      = ALLTRIM(Thisform.txtDestination.Value)
			.cEmailSubject = ALLTRIM(Thisform.txtSubject.Value)
			lcHTML = "<HTML>" + Thisform.Chtmleditor1.oIE.Document.Body.OuterHTML + "</HTML>"
			lcHTML = STRTRAN(lcHTML, "contentEditable=true", "")
			.cEmailBody = lcHTML
		
			lcAttach = ""
			WITH Thisform.CmbAttach as ComboBox 
				FOR m.i = 1 TO .ListCount
					lcAttach = lcAttach + .List(m.i, 2) + ","
				ENDFOR
			ENDWITH
			lcAttach = LEFT(lcAttach, LEN(lcAttach) - 1)
			._cAttachment   = lcAttach
		
			.lReadReceipt  = Thisform.chkReceipt.Value
			.lPriority     = Thisform.chkPriority.Value
			
			._lSendingFax  = .T.
		ENDWITH 
		
		Thisform.Release()
		RETURN
	ENDPROC

	PROCEDURE Command1.Click
		LOCAL lcAdress, lcOrigAdress
		lcAdress = ""
		TRY 
			IF NOT EMPTY(_goFP.cAdressTable) AND NOT EMPTY(_goFP.cAdressSearch)
				DO FORM pr_AdressBook ; 
					WITH _goFP.cAdressTable, _goFP.cAdressSearch ;
					TO lcAdress
		
				IF NOT EMPTY(lcAdress) AND VARTYPE(lcAdress) = "C"
					lcOrigAdress = ALLTRIM(Thisform.TxtDestination.Value)
		
					IF EMPTY(lcOrigAdress)
						Thisform.TxtDestination.Value = lcAdress
					ELSE
						Thisform.TxtDestination.Value = lcOrigAdress + ";" + lcAdress
					ENDIF 
					Thisform.TxtDestination.SetFocus()
				ELSE 
					This.LostFocus()
				ENDIF 
			ENDIF
		CATCH TO loExc
			SET STEP ON
		ENDTRY 
	ENDPROC

ENDDEFINE
