Solved

Positiioning cursor from .eml file

Posted on 2004-10-20
4
230 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

911 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

15 Experts available now in Live!

Get 1:1 Help Now