<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi Joylon<br>
<br>
No problem !<br>
<br>
I usually use Indy to send emails but in this case I wanted to use
the default email client. I HAVE found some MAPI code that seems
to work! I am working through it now. Third time lucky :)<br>
<br>
Code below for others (in its cut and paste format) ...<br>
<br>
procedure ArtMAPISendMail(<br>
const Subject, MessageText, MailFromName,
MailFromAddress,<br>
MailToName, MailToAddress: String;<br>
const AttachmentFileNames: array of String);<br>
//Originally by Brian Long: The Delphi Magazine issue 60 - Delphi
And Email<br>
var<br>
MAPIError: DWord;<br>
MapiMessage: TMapiMessage;<br>
Originator, Recipient: TMapiRecipDesc;<br>
Files, FilesTmp: PMapiFileDesc;<br>
FilesCount: Integer;<br>
begin<br>
FillChar(MapiMessage, Sizeof(TMapiMessage), 0);<br>
<br>
MapiMessage.lpszSubject := PAnsiChar(AnsiString(Subject));<br>
MapiMessage.lpszNoteText := PAnsiChar(AnsiString(MessageText));<br>
<br>
FillChar(Originator, Sizeof(TMapiRecipDesc), 0);<br>
<br>
Originator.lpszName := PAnsiChar(AnsiString(MailFromName));<br>
Originator.lpszAddress :=
PAnsiChar(AnsiString(MailFromAddress));<br>
// MapiMessage.lpOriginator := @Originator;<br>
MapiMessage.lpOriginator := nil;<br>
<br>
<br>
MapiMessage.nRecipCount := 1;<br>
FillChar(Recipient, Sizeof(TMapiRecipDesc), 0);<br>
Recipient.ulRecipClass := MAPI_TO;<br>
Recipient.lpszName := PAnsiChar(AnsiString(MailToName));<br>
Recipient.lpszAddress := PAnsiChar(AnsiString(MailToAddress));<br>
MapiMessage.lpRecips := @Recipient;<br>
<br>
MapiMessage.nFileCount := High(AttachmentFileNames) -
Low(AttachmentFileNames) + 1;<br>
Files := AllocMem(SizeOf(TMapiFileDesc) *
MapiMessage.nFileCount);<br>
MapiMessage.lpFiles := Files;<br>
FilesTmp := Files;<br>
for FilesCount := Low(AttachmentFileNames) to
High(AttachmentFileNames) do<br>
begin<br>
FilesTmp.nPosition := $FFFFFFFF;<br>
FilesTmp.lpszPathName :=
PAnsiChar(AnsiString(AttachmentFileNames[FilesCount]));<br>
Inc(FilesTmp)<br>
end;<br>
<br>
try<br>
MAPIError := MapiSendMail(<br>
0,<br>
Application.MainForm.Handle,<br>
MapiMessage,<br>
{MAPI_LOGON_UI or }{MAPI_NEW_SESSION} MAPI_DIALOG,<br>
0);<br>
finally<br>
FreeMem(Files)<br>
end;<br>
<br>
case MAPIError of<br>
MAPI_E_AMBIGUOUS_RECIPIENT:<br>
Showmessage('A recipient matched more than one of the
recipient descriptor structures and MAPI_DIALOG was not set. No
message was sent.');<br>
MAPI_E_ATTACHMENT_NOT_FOUND:<br>
Showmessage('The specified attachment was not found; no
message was sent.');<br>
MAPI_E_ATTACHMENT_OPEN_FAILURE:<br>
Showmessage('The specified attachment could not be opened;
no message was sent.');<br>
MAPI_E_BAD_RECIPTYPE:<br>
Showmessage('The type of a recipient was not MAPI_TO,
MAPI_CC, or MAPI_BCC. No message was sent.');<br>
MAPI_E_FAILURE:<br>
Showmessage('One or more unspecified errors occurred; no
message was sent.');<br>
MAPI_E_INSUFFICIENT_MEMORY:<br>
Showmessage('There was insufficient memory to proceed. No
message was sent.');<br>
MAPI_E_LOGIN_FAILURE:<br>
Showmessage('There was no default logon, and the user failed
to log on successfully when the logon dialog box was displayed. No
message was sent.');<br>
MAPI_E_TEXT_TOO_LARGE:<br>
Showmessage('The text in the message was too large to sent;
the message was not sent.');<br>
MAPI_E_TOO_MANY_FILES:<br>
Showmessage('There were too many file attachments; no
message was sent.');<br>
MAPI_E_TOO_MANY_RECIPIENTS:<br>
Showmessage('There were too many recipients; no message was
sent.');<br>
MAPI_E_UNKNOWN_RECIPIENT:<br>
Showmessage('A recipient did not appear in the address
list; no message was sent.');<br>
MAPI_E_USER_ABORT:<br>
Showmessage('The user canceled the process; no message was
sent.');<br>
SUCCESS_SUCCESS:<br>
Showmessage('MAPISendMail successfully sent the message.');<br>
else<br>
Showmessage('MAPISendMail failed with an unknown error
code.');<br>
end;<br>
end;<br>
<br>
<br>
On 28/07/2016 4:00 PM, Jolyon Direnko-Smith wrote:<br>
</div>
<blockquote
cite="mid:CALXexOqqbaJUj4kFQthH0mi_hp0fmxqUo-fy=5Fzn8Ez32_ONw@mail.gmail.com"
type="cite">
<div dir="ltr">Ignore my previous response - it was just
re-stating what you already learned. Sorry 'bout that.<br>
<br>
As for alternatives, is there any reason you must use the
default email client and cannot simply construct and send an
email using (e.g.) Indy SMTP or IMAP components, suitably
configured ?<br>
<br>
<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On 28 July 2016 at 15:58, Jolyon
Direnko-Smith <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:jsmith@deltics.co.nz" target="_blank">jsmith@deltics.co.nz</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">The mailto URI scheme does not support
attachments.<br>
<br>
<a moz-do-not-send="true"
href="https://tools.ietf.org/html/rfc6068"
target="_blank">https://tools.ietf.org/html/rfc6068</a><br>
<br>
Specific email clients may provide extensions to the URI
scheme that allow that email client to support attachments
via a mailto: URI but by definition these extensions will
not be universally supported and so fail the test of
"working with the user's default email client (whatever
that may be)".<br>
</div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On 28 July 2016 at 15:33,
Robert Martin <span dir="ltr"><<a
moz-do-not-send="true"
href="mailto:rob@chreos.co.nz" target="_blank">rob@chreos.co.nz</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">Hi
All<br>
<br>
I am trying to open the default system email
client with a new email<br>
(subject and attachment). I know about MailTo but
that doesn't support<br>
file attachments. I have tried a couple of MAPI
functions I got off the<br>
web but to no avail (one errors the other just
runs and does nothing).<br>
Does anyone have code to do this?<br>
<br>
<br>
Cheers<br>
<br>
Rob<br>
<br>
<br>
_______________________________________________<br>
NZ Borland Developers Group - Delphi mailing list<br>
Post: <a moz-do-not-send="true"
href="mailto:delphi@listserver.123.net.nz"
target="_blank">delphi@listserver.123.net.nz</a><br>
Admin: <a moz-do-not-send="true"
href="http://delphi.org.nz/mailman/listinfo/delphi"
rel="noreferrer" target="_blank">http://delphi.org.nz/mailman/listinfo/delphi</a><br>
Unsubscribe: send an email to <a
moz-do-not-send="true"
href="mailto:delphi-request@listserver.123.net.nz"
target="_blank">delphi-request@listserver.123.net.nz</a>
with Subject: unsubscribe<br>
<br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
NZ Borland Developers Group - Delphi mailing list
Post: <a class="moz-txt-link-abbreviated" href="mailto:delphi@listserver.123.net.nz">delphi@listserver.123.net.nz</a>
Admin: <a class="moz-txt-link-freetext" href="http://delphi.org.nz/mailman/listinfo/delphi">http://delphi.org.nz/mailman/listinfo/delphi</a>
Unsubscribe: send an email to <a class="moz-txt-link-abbreviated" href="mailto:delphi-request@listserver.123.net.nz">delphi-request@listserver.123.net.nz</a> with Subject: unsubscribe</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<p class="" avgcert""="" color="#000000" align="left">No virus
found in this message.<br>
Checked by AVG - <a moz-do-not-send="true"
href="http://www.avg.com">www.avg.com</a><br>
Version: 2016.0.7690 / Virus Database: 4627/12695 - Release
Date: 07/27/16</p>
</blockquote>
<p><br>
</p>
</body>
</html>