New HTML Documentation
We are happy to let you know that we have completely revised and updated the HTML documentation on www.textcontrol.com. The new docs reflect the new structure of TX Text Control.
The principle difference between the previously available documentation and what is now on the server is its structure. The new documentation is clearly divided into two sections:
- Using the TX Text Control ActiveX
- Using the TX Text Control C++ Class Library
Do not forget that you can get this documentation in PDF format as well, if you prefer to read them offline.
Top TX Tip: Sending The Contents Of A Text Control Via E-Mail
This week we are looking at a really handy trick that you can pull off with TX Text Control. In fact, we can go as far as to say that one of the most popular topics that is raised here in the Support Department is how to send the contents of a TX Text Control via e-mail.
And exactly that is the topic of this weeks' TX Top Tip.
So, you have got your text in a Text Control and you want to send that to someone on the Internet via e-mail. How do you do that?
Well, as you guessed, it is not that difficult. Indeed only last week was there a discussion in our TX Discussion Forum about this very topic. The best way to approach this problem is to send the text as an attachment. All you need to do that is the TX Text Control and the MAPISession control from the Microsoft MAPI controls.
To send the contents of a Text Control as an email attachment, create a form with a MAPIMessages and a MAPISession control, a Send button, and 2 text boxes for email address and subject. Call the code below from the Send button's Click event. The RecipAdress and MsgSubject could contain the mail information for the recipient address and the mail subject.
'
' cmdSend_Click
'
' Establish a MAPI session and send the current document as a HTML
' attachment.
'
Private Sub cmdSend_Click()
On Error GoTo err_cmdSend_Click
' Log on to MAPI session
MAPISession.SignOn
MAPIMessages.SessionID = MAPISession.SessionID
' Compose and send mail
MAPIMessages.Compose
MAPIMessages.RecipAddress = txtEmailAddress
MAPIMessages.MsgSubject = txtSubject
MAPIMessages.AttachmentPathName = CreateFileAttachment(tx)
MAPIMessages.Send True
Kill MAPIMessages.AttachmentPathName
MAPISession.SignOff
Unload Me
Exit Sub
err_cmdSend_Click:
MsgBox Err.Description
Exit Sub
End Sub
'
' CreateFileAttachment
'
' Save the current document to a temporary HTML file and return
' the file path. This file is used as an email attachment and
' must be deleted after it has been sent.
'
Private Function CreateFileAttachment(tx As TXTextControl) As String
Dim sTempFile As String
sTempFile = VBWrapper_TempPath() & "EmailAttachment.html"
tx.Save sTempFile, 0, 4, False
CreateFileAttachment = sTempFile
End Function
And that is all there is to it. We told you it was a piece of cake. If you have any problems, just send us an e-mail. We are there to help you. Whether you are an advanced user or just setting out, you are entitled to take advantage of our complementary support service. E-mail us. We are looking forward to hearing from you very shortly.
Best regards
The Newsletter Team