Solved

Positiioning cursor from .eml file

Posted on 2004-10-20
4
228 Views
Last Modified: 2010-04-05
I am using FileExec in Delphi with MailTo:'filename.eml' and the .eml file correctly comes into a send message in Outlook Express. Is there code I can add to the .eml file to position the cursor at the end of the body text?  Or something else?
Thanks in advance
0
Comment
Question by:SantMarti
4 Comments
 
LVL 1

Accepted Solution

by:
vacerose earned 250 total points
ID: 12366659
After loading the .eml file, you can enumerate the windows to locate the message window. Then you can send some windows message commands to focus the body and scroll to the bottom. I tested this code using OE 6 and Windows XP Pro.

add these enumeration functions to your app

function EnumChildProc(Handle: HWND; Info: Pointer): BOOL; stdcall;
var
  txt: array [0..255] of char;
  place:WindowPlacement;
  p:array[0..1] of WORD;
begin
  Result := True;
  GetClassName(Handle, txt, sizeof(txt)-1);
  if StrPas(txt)='Internet Explorer_Server' then
  begin
    GetWindowPlacement(Handle, @place);
    //Scroll to the bottom, this works
    PostMessage(Handle, WM_VSCROLL, SB_BOTTOM, 0);
    //focus and position cursor, simulates left mouse click
    p[0]:=0;
    p[1]:=place.rcNormalPosition.Bottom-place.rcNormalPosition.Top-10;
    PostMessage(Handle, WM_LBUTTONDOWN, 0, integer(p));
    PostMessage(Handle, WM_LBUTTONUP, 0, integer(p));
  end;
end;

function EnumWindowsProc(Handle: HWND; Info: Pointer): BOOL; stdcall;
var
  txt: array [0..255] of char;
begin
  Result := True;
  GetClassName(Handle, txt, sizeof(txt)-1);
  if StrPas(txt)='ATH_Note' then
  begin
    Result:=false;
    EnumChildWindows(Handle, @EnumChildProc, 0);    
  end;
end;


call the primary windows enumeration after the .eml has been loaded. it may be necessary to pause the app to give OE time to load...
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
  EnumWindows(@EnumWindowsProc, 0);
end;
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now