I have been using:
ShellExecute(Self.Handle,
nil, PCHAR(format('mailto:%s ?Subject=Assunto: &Body=',[_lEmails ])),
nil,
nil,
SW_NORMAL);
to send emails.
No Body text so the users that have automatic signatures in their emails clients get those automatically.
Now I want to enable users to insert text as well, but if they do the text gets there but no signature.
Is there a way to "force" this.
Thanks
You can use MAPI instead (the Messaging Applications Programming Interface
), which gives you much better control over the email, and allows things like attachments. You can also choose whether to show the user's email client "compose" window or add directly to the outbox. (The outbox functionality is usually restricted now because of changes to Windows security, especially where MS Outlook is concerned.)
The quickest, easiest way is to use something like the JEDI Code Library JCLEMail
. It's a wrapper around SimpleMAPI, which makes it very easy (code was taken from an older app, and was based on a sample from the JCL demo):
EMail := TJclEMail.Create;
try
EMail.Recipients.Add(AnsiString(EMailAddress), AnsiString(EMailName));
EMail.Subject := AnsiString(Subject);
EMail.Body := AnsiString(Body);
EMail.HtmlBody := False; // True if it's HTML email
// Send attachment if wanted
EMail.Attachments.Add(AnsiString(FileName));
EMail.Send(True); // True to show default email, false to add to outbox
finally
EMail.Free;
end;
The drawback to SimpleMAPI
is that it may be a short-term solution (although it's still around in Win7 64-bit and earlier, I can't speak for Windows 8). According to MSDN,
[The use of Simple MAPI is discouraged. It may be altered or unavailable in subsequent versions of Windows.]
The drawback to MAPI
is that it relies on a MAPI
client being installed. Fortunately, almost any software that supports mailto
should support MAPI
as well; Outlook does, for instance, and so does Mozilla Thunderbird.
On ensuring the default signature appears (if that was the crux of the question, if not sorry, I have misread), then appears you may be out of luck (as I've been trying to do this).
The below MS article appears to say "no". It appears to imply that versions of Outlook up to 2010 wont support defaulting email signatures when creating emails via MAPI. It doesn't seem to offer much of a reason, and advises that you simply use the "insert signature" option in the email dialog (which to me, isnt a real help when you may want it defaulted and perhaps for the email to just "go" without user intervention).
http://support.microsoft.com/kb/2544665