lose tabs trying to take a richedit and pass it to email using "sendto:...&body="

Posted on 2003-03-15
Medium Priority
Last Modified: 2013-11-22
I have a log file with lines that look like this when i view the value of richedit variables holding them in the editor:

'Unit1 '#9' This.Text.Value'
'Unit13 '#9' This.Text.Value'

I want to use emailto's &body= to send it to the email client and look normal.  It seems to ignore all formatting.  I solved my first problem of it losing CR/LF's by using the RichEdit lines property to line by line add them.  Is there any easier way to convert this so it shows up in the message indented the way it should?  Something that maybe is a different format than richedit that might take care of it automatically?  The log should look like this:

Unit1    This.Text.Value
Unit13   This.Text.Value
Unit132  <<special note here>>
             more indent
Unit155  End it here

What I get is:

Unit1 This.Text.Value
Unit13 This.Text.Value
Unit132 <<special note here>>
more indent
Unit155 end it here

I have tried to search for the #9 to do replaces based on it's position, but even though the #9 should be at a different position since Unit1 and Unit13 have a different length, the tab always shows the same position at position 10 in the string.  Are there other invisible characters I can't see in the Richedit string?

Here is what I have, but it will only add spaces between the Unit words and the text after the #9 since it always shows as position 10 when I think the tab should vary based on the length of that first word after which it should occur:

procedure TFormLog.SpeedButtonEmailClick(Sender: TObject);
  var CurrentLog:                      TRichEdit;
      i,x,position,numspaces:          Integer;
      tempbodytextStr, MybodyTextStr2: String;
      dest, str:                       string;
  CurrentLog := GetCurrentLog;

  with CurrentLog do
    for i:=0 to Lines.Count-1 do     // one at a time, edit my RichEdit log lines
        Str := '';                    
        dest := CurrentLog.Lines[i]; // shows line is ' Unit1 '#9' this.value.text '
        Position := Pos(#9, dest);   // search for my tab chars, but it's always 10!!!
        Delete(Dest, Position, 2);
        NumSpaces := 15 - Position;  // calculate how many %20's to add to replace tab
        for x:=0 to NumSpaces do    
            Str := Str + hexspace;  
        Insert(Str, dest, Position); // insert spaces where I deleted the tab
        tempbodytextStr:=Dest;       // take the new line as my temp body line
        MyBodyTextStr2 := MyBodyTextStr2 + TempBodyTextStr + hexCrLf;
        // still richedit strings, add each line to the previous to build
        // the log and add CR/LF's, pass it below to email client

// try to put this string into the &body tag of the mailto: command.  I can't get it
// to be tabbed out propery

ShellExecute(handle, 'open', Pchar('mailto:' + myemailStr + '?Cc=' + myccStr + '&Subject=' + mysubjectStr + '&Body=' + mybodytextStr2), nil, nil, SW_SHOWNORMAL);


Thanks everybody, I know it's my fault for not understanding all the different text format possibilities between Delphi and the emails body text, but I can't see what's going on.

Question by:fdecker
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 8154501
I'm just browsing through the questions, and I saw you's about RichText.
I've recently been working a bit with RichText, and had problems combining two RichEdit boxes.

The problem seemed to be, I was working with the "lines" - as I beleive you do too. This doesn't contain the "formatting".

What I had to do, was a select all on the RichEdit, copy to clipboard, and paste from clipboard.

Maby you can use this also ?


Author Comment

ID: 8160946
I have tried what you said, except I stream to memory and back, but that's not really the answer.  I have a bigger problem now anyway and realized that you can only send 255 characters using the shellexecute mailto line.  The mailto: using &body is basically useless and I have to find a better way.  The option of using the SMTP tools that come with Delphi 7 will work, but not a great option as it really complicates the code and we have all the issues of what server do you go through?  It would be perfect to have code that would call up the default email client on that person's machine and dump a whole text file into it's body.  That's what I really need.


Expert Comment

ID: 9316759
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.

Accepted Solution

modulo earned 0 total points
ID: 10639936
PAQed, with points refunded (50)

Community Support Moderator

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question