 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Danila Vershinin Guest
|
Posted: Thu Jun 09, 2005 3:08 pm Post subject: Link to send an email with predefined text. |
|
|
Hi,
In my program, to let user tell me about any problems he/she encounters when
the program works, I've made a TLabel, clicking which you force the default
email program open up with a blank message.
I get this functionality from ShellExecute function, specifying the link to
open email program as lpFile parameter.
The link has the following form,
mailto:emailaddress (AT) domain (DOT) com?Subject=this is my subject line
The question is,... is that possible to add smth to the link so that I will
get not the subject line only, but also the text of the message itself?.
Maybe I should add "?Message =...." ?
Same question about email attachments.
Thanks in advance.
|
|
| Back to top |
|
 |
Antonio Felix Guest
|
Posted: Thu Jun 09, 2005 4:02 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Danila Vershinin" <danprep (AT) yahoo (DOT) com> wrote:
| Quote: | Hi,
In my program, to let user tell me about any problems he/she encounters when
the program works, I've made a TLabel, clicking which you force the default
email program open up with a blank message.
I get this functionality from ShellExecute function, specifying the link to
open email program as lpFile parameter.
The link has the following form,
mailto:emailaddress (AT) domain (DOT) com?Subject=this is my subject line
The question is,... is that possible to add smth to the link so that I will
get not the subject line only, but also the text of the message itself?.
Maybe I should add "?Message =...." ?
Same question about email attachments.
Thanks in advance.
|
Hi Danila,
Instead of ShellExecute you may use MapiSendMail:
// On your TLabel Click Handler
TMapiMessage MapiMsg;
TMapiRecipDesc MapiDsc[1];
MapiFileDesc *FileDesc;
Cardinal MError;
MapiDsc[0].ulReserved = 0;
MapiDsc[0].ulRecipClass = 1;
MapiDsc[0].lpszName = "YourName";
MapiDsc[0].lpszAddress = "SMTP:Your.Name (AT) MailAddress (DOT) Pt";
MapiDsc[0].ulEIDSize = 0;
MapiDsc[0].lpEntryID = NULL;
FileDesc = new MapiFileDesc();
FileDesc->ulReserved = 0;
FileDesc->flFlags = 0;
FileDesc->nPosition = 0;
FileDesc->lpszPathName = "C:\Attachement.Txt";
FileDesc->lpszFileName = NULL;
FileDesc->lpFileType = NULL;
MapiMsg.ulReserved = 0;
MapiMsg.lpszSubject = "Mail Subject";
MapiMsg.lpszNoteText = "";
MapiMsg.lpszMessageType = NULL;
MapiMsg.lpszDateReceived = NULL;
MapiMsg.lpszConversationID = NULL;
MapiMsg.flFlags = 0;
MapiMsg.lpOriginator = NULL;
MapiMsg.nRecipCount = 1;
MapiMsg.lpRecips = &MapiDsc[0];
MapiMsg.nFileCount = 1;
MapiMsg.lpFiles = FileDesc;
// Check the Help in order to use the desired Flags
// this is only a possible use
MError = MapiSendMail( 0, 0, MapiMsg, MAPI_DIALOG | MAPI_LOGON_UI | MAPI_NEW_SESSION, 0 );
if ( MError ) {
// Handle error here or display a warning message
}
delete FileDesc;
PS: You must include the header file Mapi.Hpp
HTH
Antonio
|
|
| Back to top |
|
 |
Danila Vershinin Guest
|
Posted: Thu Jun 09, 2005 5:04 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Antonio Felix" <nomail (AT) nm (DOT) pt> wrote
| Quote: | // On your TLabel Click Handler
|
Hi Antonio,
thank you very much for the code you gave,
I now have kinda problem implementing it.
when I put it in the TLabel OnClick handler it brings on the message
window.... but...
The window is not just modal, it's completely not editable. I mean it is
shown but I can't seem to interact with it, at all ..
Though putthing the code in the form constructor does not give the behavior
mentioned above...
So what should I do with it, I need it on label/button click.. not the
form's constructor :)
|
|
| Back to top |
|
 |
Antonio Felix Guest
|
Posted: Thu Jun 09, 2005 5:39 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Danila Vershinin" <danprep (AT) yahoo (DOT) com> wrote:
| Quote: | "Antonio Felix" <nomail (AT) nm (DOT) pt> wrote in message
news:42a8681f$1 (AT) newsgroups (DOT) borland.com...
// On your TLabel Click Handler
Hi Antonio,
thank you very much for the code you gave,
I now have kinda problem implementing it.
when I put it in the TLabel OnClick handler it brings on the message
window.... but...
The window is not just modal, it's completely not editable. I mean it is
shown but I can't seem to interact with it, at all ..
Though putthing the code in the form constructor does not give the behavior
mentioned above...
So what should I do with it, I need it on label/button click.. not the
form's constructor :)
|
Hi Danila,
That's odd, i'm using it from a OnClick Event of a TLabel
without any problem.
Are you using the same Mapi Flags ?
Under what OS ?
I'm using it under Win2K & XP SP1 with Outlook just fine.
It shoudn't mater if called form the constructor or the
OnClick Event !!?
Br
Antonio
|
|
| Back to top |
|
 |
Danila Vershinin Guest
|
Posted: Thu Jun 09, 2005 5:59 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Antonio Felix" <nomail (AT) nm (DOT) pt> wrote
| Quote: | That's odd...
Are you using the same Mapi Flags ?
It shoudn't mater if called form the constructor or the OnClick Event !!?
|
Antionio, I completely agree that it shouldn't matter, but well, for reason
unknown, it does, at least on my machine.
XP SP2, Outlook Express 6.
Using the code unchanged at all doesn't bring ANYTHING on...
The only things that I have changed are:
FileDesc->lpszPathName = "C:\Attachement.Txt"; >>>
FileDesc->lpszPathName = NULL;
MapiMsg.nFileCount = 1; >> MapiMsg.nFileCount = 0;
Everything becomes so very modal... .. that I can not interact with
anything at all, since the new message dialog is modal, and I even have to
shutdown the program with "Program Reset" of the debugger .....
|
|
| Back to top |
|
 |
Danila Vershinin Guest
|
Posted: Thu Jun 09, 2005 7:09 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Antonio Felix" <nomail (AT) nm (DOT) pt> wrote
| Quote: | I'm using it under Win2K & XP SP1 with Outlook just fine.
|
Now I believe that it refers to what my Outlook Expree does. That New
Message Window seems to try to get the functionality of the main form.
I did this trick: created a secondary form at design time, so it is not
automatically created at runtime. (removed from the Auto-create forms list).
In the constructor of that secondary form I've put the code to send email.
The form was created on the click of a button on the main form.....
And yet, again I see this strange behavior .... So the situation is clear,
but not completely. As long as the application have no forms created, once
the New Message window is created, it is possible to interact with it and it
doesn't return until it is closed.
BTW, sorry for spelling your name wrong.
|
|
| Back to top |
|
 |
Jonathan Benedicto Guest
|
Posted: Thu Jun 09, 2005 7:30 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Danila Vershinin" <danprep (AT) yahoo (DOT) com> wrote
| Quote: | Now I believe that it refers to what my Outlook Expree does. That
New
Message Window seems to try to get the functionality of the main
form.
I did this trick: created a secondary form at design time, so it is
not
automatically created at runtime. (removed from the Auto-create
forms list).
In the constructor of that secondary form I've put the code to send
email.
The form was created on the click of a button on the main form.....
And yet, again I see this strange behavior .... So the situation
is clear,
but not completely. As long as the application have no forms
created, once
the New Message window is created, it is possible to interact with
it and it
doesn't return until it is closed.
|
Try changing the MapiSendMail line to:
MError = MapiSendMail( 0, (ULONG)(Application->Handle), MapiMsg,
MAPI_DIALOG | MAPI_LOGON_UI | MAPI_NEW_SESSION, 0 );
It fixed the error on my computer, XP SP2.
HTH
Jonathan
|
|
| Back to top |
|
 |
Danila Vershinin Guest
|
Posted: Thu Jun 09, 2005 8:11 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Jonathan Benedicto" <incorrect (AT) no (DOT) server> wrote
| Quote: | MError = MapiSendMail( 0, (ULONG)(Application->Handle), MapiMsg,
MAPI_DIALOG | MAPI_LOGON_UI | MAPI_NEW_SESSION, 0 );
|
Thanks a lot, Jonathan! It did help!!!!)
|
|
| Back to top |
|
 |
Antonio Felix Guest
|
Posted: Thu Jun 09, 2005 10:05 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Danila Vershinin" <danprep (AT) yahoo (DOT) com> wrote:
| Quote: | "Jonathan Benedicto" <incorrect (AT) no (DOT) server> wrote in message
news:42a89f3e$1 (AT) newsgroups (DOT) borland.com...
MError = MapiSendMail( 0, (ULONG)(Application->Handle), MapiMsg,
MAPI_DIALOG | MAPI_LOGON_UI | MAPI_NEW_SESSION, 0 );
Thanks a lot, Jonathan! It did help!!!!)
|
Sorry,
i've been off-line for a while...
It seems that XP SP2 makes the diference!
I'm using it under SP1, called from a TLabel as you've tried
with no problems at all.
It seems that the Window Handle is now required!
Br
Antonio
|
|
| Back to top |
|
 |
Lars Brange Guest
|
Posted: Fri Jun 10, 2005 10:23 am Post subject: Re: Link to send an email with predefined text. |
|
|
Hi,
You could try this. I'm not sure if every mail program recognizes all
parameters. You must URL encode the string; at a minumum replace spaces
with %20.
mailto:someone (AT) domain (DOT) com?cc=someoneelse (AT) domain (DOT) com&bcc=andsomeoneelse2 (AT) domain (DOT) com&subject=Summer%20Party&body=You%20are%20invited%20to%20a%20big%20summer%20party!
Lars Brange
Danila Vershinin wrote:
| Quote: | Hi,
In my program, to let user tell me about any problems he/she encounters when
the program works, I've made a TLabel, clicking which you force the default
email program open up with a blank message.
I get this functionality from ShellExecute function, specifying the link to
open email program as lpFile parameter.
The link has the following form,
mailto:emailaddress (AT) domain (DOT) com?Subject=this is my subject line
The question is,... is that possible to add smth to the link so that I will
get not the subject line only, but also the text of the message itself?.
Maybe I should add "?Message =...." ?
Same question about email attachments.
Thanks in advance.
|
|
|
| Back to top |
|
 |
Danila Vershinin Guest
|
Posted: Fri Jun 10, 2005 2:03 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Lars Brange" <lars.brange (AT) aurum (DOT) se> wrote
| Quote: | You could try this. I'm not sure if every mail program recognizes all
parameters.
|
Thank you, Lars! This is exactly what I wanted
Though it was also good to know how it can be done in the context of MAPI
programming.
Thanks all the guys who posted in the thread.
|
|
| Back to top |
|
 |
Leroy Casterline Guest
|
Posted: Tue Jun 14, 2005 3:25 pm Post subject: Re: Link to send an email with predefined text. |
|
|
"Danila Vershinin" <danprep (AT) yahoo (DOT) com> wrote:
Have you looked at madExcept? It's an outstanding exception handling
component that can (if you wish) send an exception report by email. The
report (optionally) contains tons of information about the app and
(again optionally) a screen shot, as well as any info you want to add.
It works very well.
I haven't used it this way, but as I recall you can use its email
functionality manually as well.
Free for non-commercial use, inexpensive for commercial apps, very well
supported. http://www.madexcept.com/
|
|
| Back to top |
|
 |
David Erbas-White Guest
|
Posted: Tue Jun 14, 2005 4:20 pm Post subject: Re: Link to send an email with predefined text. |
|
|
Leroy Casterline wrote:
I'll second the recommendation for madExcept. Been using it for a
while, it's been invaluable.
David Erbas-White
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|