Jump to content

stringreplace in outlook


Recommended Posts

what i am trying to do is cut some text from the body of an email and then paste it back with text: at the beginning of each line. Smoken led me in the direction of stringreplace which does a good job (just doesnt get it right) The code i am using is

CODE
send("^a")

send("^c")

$Body = ClipGet()

;find replace

$Body = StringReplace($Body, @CR , @CR & "Text:")

$Body = "Text:" & $Body

ClipPut($Body)

send("^a")

send("{DEL}")

send("^v")

The problem is i still end up with a carriage return after each text: bit. i can do this via sendkey with outlokk by doing a find and replace with paragraph markers. So what the hell is a paragraph marker, if you dont know, do you know if there is a way that i can get a string typed out in ascii codes so that i can see what the hell it is that i should be searching for and replacing.

Link to comment
Share on other sites

Hi NTBM,

It's a little bit quick and dirty, but try this:

dim $aBodysplit, $iPosition, $sTemp

send("^a")
send("^c")
$Body = ClipGet()
;find replace

while StringInStr($Body,@CR,0) <> 0
    $iPosition = StringInStr($Body,@CR,0)
    if StringLen(StringLeft($Body,$iPosition)) > 1 Then
        $aBodysplit = $aBodysplit & "Text: " & StringLeft($Body,$iPosition) & @CRLF
    Else
        $aBodysplit = $aBodysplit & @CRLF
    endif
    $Body = StringMid($Body,$iPosition + 2)
wend

; Past the rest of the $Body string (except last @cr)
if StringLen($Body) > 1 then
    $aBodysplit = $aBodysplit & "Text: " & $Body
EndIf

ClipPut($aBodysplit)
send("^a")
send("{DEL}")
send("^v")

Does this solves your problem?

Greets,

Tim.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...