Advertisement

08.08.2007 at 10:41AM PDT, ID: 22750078
[x]
Attachment Details

Send Outlook Express emails in the background

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.0
Tags:

outlook, delphi, express, send

Using Delphi7, I am attempting to send emails from my application. I know that there are many ways to do this easily, and in some parts of my app I am creating an email and having the new email form come up (so that the user can amend the email and then click "Send").

However, I need to perform some email tasks in the background and I do not want to use as smtp server due to it needing to be configured (host, username,etc...). I can get the email created and sent fine, without the new email form coming up BUT the Outlook Send/Receive form comes to the foreground and basically locks out my app until the emails are sent!

I have looked at locating the window handle and trying to minimise it, but this is not possible as the MAPI commands are outside of Delphi and the mapi.pas unit is only a wrapper for these functions.

Can anybody help???


Code snippet for current email sending is below:


procedure SendMailDialog(Recip, Subject, Body, Attach : string; ShowDialog : boolean);
var
  mapiMsg : TMapiMessage;
  smapiRecip : TMapiRecipDesc;
  mapiFileDetail : TMapiFileDesc;
  AFile : String;
begin

  FillChar(mapiMsg, SizeOf(mapiMsg), 0);
  FillChar(smapiRecip, SizeOf(smapiRecip), 0);
  FillChar(mapiFileDetail, SizeOf(mapiFileDetail), 0);

  smapiRecip.ulRecipClass := MAPI_TO;
  smapiRecip.lpszName := '';
  smapiRecip.lpszAddress := PChar(Recip);

  mapiFileDetail.lpszPathName := PChar(Attach);
  AFile := ExtractFilename(Attach);
  mapiFileDetail.lpszFileName := PChar(AFile);

  mapiMsg.lpszSubject := PChar(Subject);
  mapiMsg.lpszNoteText := PChar(Body);
  mapiMsg.nRecipCount := 1;
  mapiMsg.lpRecips := @smapiRecip;
  mapiMsg.nFileCount := 1;
  mapiMsg.lpFiles := @mapiFileDetail;

  if ShowDialog then
    MapiSendMail(0, 0, mapiMsg, MAPI_LOGON_UI+MAPI_DIALOG, 0)
  else
  begin
    MapiSendMail(0, 0, mapiMsg, 0, 0);
  end;
 
end;
Answered By: EddieShipman
Expert Since: 02/23/2000
Accepted Solutions: 1206
EddieShipman has been an Expert for 8 years 10 months, during which he has posted 6296 comments and answered 1206 questions. EddieShipman is just one of 84 experts in the Windows OLE Programming Zone. 3 experts collaborated on this answer, which was graded an "A" by the asker.
 
 
 
 
20081119-EE-VQP-47 / EE_QW_1_20070628