WriteStringToFile Method


Writes the specified string into the specified file.

The method lets you specify the codepage to use when saving the string (which is a sequence of 16-bit Unicode characters) into the file (which is a sequence of 8-bit bytes). If you know only the charset name but not the codepage, you can get the codepage number with GetCodepageFromCharset method.

This is a helper method you can use for writing any strings to files. For instance, you can use it to write your own entries into MailBee log files.


blnResult = ObjectName.WriteStringToFile(Filename, Data, [Overwrite], [Codepage])  
Parameters:  
Filename As String The file path to the file.  
Data As String The string to write to file.  
Overwrite As Boolean (optional) If True, MailBee will overwite the file. If False (the default value), MailBee will append to the file. Anyway, the file will be created if it does not exist.  
Codepage As Long (optional) The codepage of the encoding to use when writing the string into the file. By default, the system's default codepage 0 is used.  
Return value As Boolean True on success, False on error.  

Usage example:

Dim Msg, dDateTime
'Using visual basic to create object
Set Msg = CreateObject("MailBee.Message")
'Using ASP to create object
'Set Msg = Server.CreateObject("MailBee.Message")
'In ASP use Response.Write instead of MsgBox
If Msg.WriteStringToFile("C:\Temp\logfile.txt", "log file entry" & vbCrLf) Then
  MsgBox "OK"
Else
  MsgBox "Error"
End If

See Also:

GetCodepageFromCharset Method


Copyright © 2002-2024, AfterLogic Corporation. All rights reserved.