Replace a character in the content of the body with a string.
Syntax:
Parameters:
- sCharList – Set of characters that, if found, will be replaced by the specified string sReplaceStr . Only a single character in this set is replaced by the string.
- sStrAbsentIn – Substring not to replace. This substring is not replaced even if any character in sCharList is present in the substring.
- sReplaceStr – The string that replaces the occurrence of the character specified in sCharList.
Returns:
Returns 1 if the operation is successful; otherwise returns 0 if the operation fails.
Remarks:
Example 1. Replace any single occurrence of the character "A" and "B" with "XYZ", but do not replace any of occurrence of the substring "ABC". Assume the content of the body is "WHAT ABOUT ABCOULOMB?". The method call would be:
object.ReplaceCharNotInStr("AB", "ABC", "XYZ")
The resulting body will be modified to (bold is for emphasis only):
WHXYZT XYZXYZOUT ABCOULOMXYZ?
Example 2. Replace any single occurrence of the character "A" and "B" with "XYZ". Assume the content of the file is "WHAT ABOUT ABCOULOMB?". The method call would be:
object.ReplaceCharNotInStr("AB", "", "XYZ")
The resulting body will be modified to (bold is for emphasis only):
WHXYZT XYZXYZOUT XYZXYZXYZOULOMXYZ?
This method is useful for canonicalizing the message body. One of the process to canonicalize text is to replace any single occurrences of carriage-return (CR) or line-feed (LF) characters with the carriage-return line-feed (CRLF) pair to indicate the end of line. The single CR and LF do not include those already in the CRLF sequence.
object.ReplaceCharNotInStr(vbCrLf, vbCrLf, vbCrLf)
The example Visual Basic statement above is explained as follows. (The VB constant vbCrLf is the CRLF sequence.)
The first vbCrLf is the character set containing CR and LF to be replaced. The second vbCrLf is the substring that cannot be replaced if it is present in the file. The third vbCrLf is the string to replace any single occurrence of CR or LF.