Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Silent mailto with ShellExecute or alternative

Posted on 2003-12-02
Medium Priority
Last Modified: 2012-06-21
I can do a mailto by doing
easily setting the email to address, subject and body.

What I want to do is have a silent send to the email cleint outbox and not open the email at all. Can this be done with ShellExecute?

If not, is there another reliable way? This is for an inhouse app where outlook and outlook express are the email client so it doesn't have to be more rebust though I would ideally like not to have the email cleint as a prerequisite  

Thanks, Tom.

ps. Compiler : D5.

Question by:tomcorcoran
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
LVL 26

Expert Comment

ID: 9860151
Incorporate a SMTP component in your app, such as TidSMTP from the Indy suite.
Then all you will have to do is ask your user to enter their email host, account and password
when installing your app.

Expert Comment

ID: 9860425
Or you could use the MAPI interface, which is supported in D5 - look at MAPI.pas and see if this helps.

Accepted Solution

roknjohn earned 200 total points
ID: 9860891
call this with Showdialog = false

uses mapi;

procedure SendMailDialog(Recip, Subject, Body, Attach : string; ShowDialog : boolean);
  mapiMsg : TMapiMessage;
  // mapiRecip : TMapiRecipDesc;
  smapiRecip : TMapiRecipDesc;
  mapiFileDetail : TMapiFileDesc;
  //r : Integer;
  AFile : String;
  FillChar(mapiMsg, SizeOf(mapiMsg), 0);
  // FillChar(mapiRecip, SizeOf(mapiRecip), 0);
  FillChar(smapiRecip, SizeOf(smapiRecip), 0);
  FillChar(mapiFileDetail, SizeOf(mapiFileDetail), 0);

  {mapiRecip.ulRecipClass := MAPI_ORIG;
  mapiRecip.lpszName := 'paks';
  mapiRecip.lpszAddress := 'emailaddr';}

  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.lpOriginator := @mapiRecip;
  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)
    MapiSendMail(0, 0, mapiMsg, 0, 0);
Independent Software Vendors: 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!


Author Comment

ID: 9862352
Thanks for your comments guys. Eddie, if I use the Indy component will it contact the smtp server directly and bypas the email client sent box? I need a record kept in the sent box. If not, perhaps the mapi solution is the way forward though I am going to be using Indy also for some ftping. so if it can do the former, great.

Thanks a lot, Tom.

Expert Comment

ID: 9862717
If you want a copy in the "sent" folder then you'll have to use MAPI.  (My routine above works well, even lets you have attachments)

Or use the free TEmail component, available thru www.torry.net.  Or ask me, and  I'll send it to you.

Assisted Solution

cqhall earned 100 total points
ID: 9867082
How can you avoid having the email client as a prerequisite AND expect the email client to save a copy of the sent message?

I don't think Outlook Express adequately supports MAPI, but Outlook supports both simple MAPI and Extended MAPI.  Simple MAPI is often used by scripted viruses, so Microsoft has made simple MAPI problematic.  You'll really want to use Extended MAPI if your system administrators have applied certain security patchs to Exchange that result in popup warnings that a program is accessing Exchange "on your (user's) behalf" or accessing the Global Address List, etc.  

 If you go the extended MAPI approach, I recommend EasyMAPI (www.rapware.com)  which costs $49 for a single developer without source code or $199 with source.  They have a trial version with examples.
We bought the site license for $499 with source ($199 without) because we have several developers using it.  There is still a learning curve with EasyMAPI, but the examples will show you how to do emails and a lot more. Also, you will have the choice whether to save a copy in the user's sent folder if you automatically send email.  If you show the email dialog, EasyMAPI will respect the user's preference of saving / not saving messages in the sent folder.  Incidentally, Outlook does not have to be running, but if it isn't you can get into issues if multiple profiles are present or if the default profile is password protected.

Another resource is www.IMIBO.COM.  You'll need to register ($49 and up) to get the source code to their examples.  Incidentally, I spent weeks on Extended MAPI (including examples from IMIBO) without making a dent in it until I discovered EasyMAPI.   Try EasyMAPI first.


Expert Comment

ID: 9867124
>>How can you avoid having the email client as a prerequisite AND expect the email client to save a copy of the sent message?

I don't think that is what he is asking.  I think he just wants Outlook to go ahead and send the e-mail (quietly) without any user response or notification.  I do this in many of my applications.  Both solutions that I offered, will do just that.

Expert Comment

ID: 9867708
>>I don't think that is what he is asking.

In his original question, tomcorcoran stated "though I would ideally like not to have the email cleint as a prerequisite".  He replied to EddieShipman's SMTP approach with " I need a record kept in the sent box. ".  

>> "send the e-mail (quietly) without user response or notification".

I do this in numerous applications as well, and simple MAPI isn't suitable anymore (depending on administratively controlled security settings).  Originally, I was using simple MAPI (TEmail and OfficePartner) and it worked fine, but we "upgraded" to Outlook 2002/XP, which included default security options that caused popup messages that were unacceptable.  These security measures are also part of an update for Outlook 2000 (and probably other versions) that could be an issue.

If tomcorcoran wants to save a copy in his sent mail, and his environment includes the security issues I've described, then Extended MAPI may be the best and possibly only approach.  

Expert Comment

ID: 9867963
You are correct, CQ.  I was just going by his opening line..

>>What I want to do is have a silent send to the email cleint outbox and not open the email at all

I have one installation with about 100 users on a very secure (State Government) Novell network running XP and Groupwise.  Looking back at my source, I see that I used the TEmail component, modified slightly.  Tom, feel free to try it.

Component source code
http://www.jcent.com/jcEmail.zip    (case-sensitive)

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

598 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