Home All Groups Group Topic Archive Search About

"Send To Mail Recipient"

Author
25 Apr 2006 3:30 PM
cj
How can I get a button in VB to send the contents of a text box via
email in a manner similar to the "Send To\Mail Recipient" functionality
that you can select via right clicking a file in Windows Explorer?

I want the user to click a button and it lunch the users default email
client and put the contents of a multi line text box in the body of the
message and the contents of another text box in the title box and be
sitting there read for them to type the recipient's name and hit send.
I assume this is easily doable but I don't know where to begin.

Author
25 Apr 2006 6:44 PM
Mike Lowery
Here's an example:
http://www.ostrosoft.com/smtp_component/smtp_vbnet.asp

Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:%23I$e70HaGHA.1192@TK2MSFTNGP03.phx.gbl...
> How can I get a button in VB to send the contents of a text box via email in a
> manner similar to the "Send To\Mail Recipient" functionality that you can
> select via right clicking a file in Windows Explorer?
>
> I want the user to click a button and it lunch the users default email client
> and put the contents of a multi line text box in the body of the message and
> the contents of another text box in the title box and be sitting there read
> for them to type the recipient's name and hit send. I assume this is easily
> doable but I don't know where to begin.
Author
25 Apr 2006 8:18 PM
cj
That actually sends the email.  That's impressive, but I just wanted to
launch the default email program, create a new message and fill in the
subject and add some text to the message body.  Leave it for the person
to review, change and send.


Mike Lowery wrote:
Show quoteHide quote
> Here's an example:
> http://www.ostrosoft.com/smtp_component/smtp_vbnet.asp
>
> "cj" <cj@nospam.nospam> wrote in message
> news:%23I$e70HaGHA.1192@TK2MSFTNGP03.phx.gbl...
>> How can I get a button in VB to send the contents of a text box via email in a
>> manner similar to the "Send To\Mail Recipient" functionality that you can
>> select via right clicking a file in Windows Explorer?
>>
>> I want the user to click a button and it lunch the users default email client
>> and put the contents of a multi line text box in the body of the message and
>> the contents of another text box in the title box and be sitting there read
>> for them to type the recipient's name and hit send. I assume this is easily
>> doable but I don't know where to begin.
>
>
Author
26 Apr 2006 5:52 AM
CMM
AKAIK, the easiest way to do this is using the classic MAPI32 ActiveX
controls... yes it works with whatever e-mail is the default (both Outlook
and OE and any E-mail client that follows Windows Standards)... and you can
use it from .NET.

http://activex.microsoft.com/controls/vb6/MSMAPI32.CAB

Not sure if .NET 2.0 has the feature built-in.... but there should be no
shame in using COM components in .NET if there no .NET alternative....
Visual Studio IDE itself is a BIG *COM* application.

Example that I think does what you ask once you add a reference to
MSMAPI32.OCX:

MAPISession1.DownLoadMail = False
MAPISession1.SignOn
MAPISession1.NewSession = True

MAPIMessages1.SessionID = MAPISession1.SessionID

MAPIMessages1.Compose
MAPIMessages1.RecipAddress = "some***@somewhere.com"
MAPIMessages1.msgSubject = "My subject"
MAPIMessages1.msgNoteText = "bla bla bla"

'leave this out to keep the window open
MAPIMessages1.Send

MAPISession1.SignOff
MAPISession1.NewSession = False


--
-C. Moya
www.cmoya.com
Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:uNpDkVKaGHA.504@TK2MSFTNGP03.phx.gbl...
> That actually sends the email.  That's impressive, but I just wanted to
> launch the default email program, create a new message and fill in the
> subject and add some text to the message body.  Leave it for the person to
> review, change and send.
>
>
> Mike Lowery wrote:
>> Here's an example:
>> http://www.ostrosoft.com/smtp_component/smtp_vbnet.asp
>>
>> "cj" <cj@nospam.nospam> wrote in message
>> news:%23I$e70HaGHA.1192@TK2MSFTNGP03.phx.gbl...
>>> How can I get a button in VB to send the contents of a text box via
>>> email in a manner similar to the "Send To\Mail Recipient" functionality
>>> that you can select via right clicking a file in Windows Explorer?
>>>
>>> I want the user to click a button and it lunch the users default email
>>> client and put the contents of a multi line text box in the body of the
>>> message and the contents of another text box in the title box and be
>>> sitting there read for them to type the recipient's name and hit send. I
>>> assume this is easily doable but I don't know where to begin.
>>
Author
26 Apr 2006 8:54 AM
Aziz
http://www.systemwebmail.com/faq/2.aspx

Or probably just easier to use:

System.Diagnostics.Process.Start("mailto:" & txtEmail & "?Subject=" &
txtSubject" & "?Body=" & txtBody )
Author
26 Apr 2006 9:38 AM
CMM
I don't think the "body" parameter of mailto: is standard... not sure if its
consistently implemented by all e-mail clients. I would hope in today's day
and age they all do.

P.S.
System.Web.Mail is deprecated in .NET 2.0. For 2.0 users, the link should
be:
http://www.systemnetmail.com/ But in any case, the OP wants to trigger the
default E-mail program not worry about SMTP servers and stuff like that.

--
-C. Moya
www.cmoya.com
Show quoteHide quote
"Aziz" <aziz***@googlemail.com> wrote in message
news:1146041652.887528.214090@i40g2000cwc.googlegroups.com...
> http://www.systemwebmail.com/faq/2.aspx
>
> Or probably just easier to use:
>
> System.Diagnostics.Process.Start("mailto:" & txtEmail & "?Subject=" &
> txtSubject" & "?Body=" & txtBody )
>
Author
28 Apr 2006 8:32 PM
cj
Just got time to try the suggestions I got.

Aziz, this is a great way of launching the email client!

CMM, apparently body isn't standard in Mozilla Thunderbird anyway.  I'll
have to try it under Outlook.

Really would like for it to handle both.  Any other info anyone can
provide would be appreciated.  I'm going to search the web for awhile
and see what I can come up with.


CMM wrote:
Show quoteHide quote
> I don't think the "body" parameter of mailto: is standard... not sure if its
> consistently implemented by all e-mail clients. I would hope in today's day
> and age they all do.
>
> P.S.
> System.Web.Mail is deprecated in .NET 2.0. For 2.0 users, the link should
> be:
> http://www.systemnetmail.com/ But in any case, the OP wants to trigger the
> default E-mail program not worry about SMTP servers and stuff like that.
>
Author
28 Apr 2006 8:42 PM
cj
That didn't take long.  I still need to try it in Outlook but in
Thunderbird change ?body to &body and it works!

cj wrote:
Show quoteHide quote
> Just got time to try the suggestions I got.
>
> Aziz, this is a great way of launching the email client!
>
> CMM, apparently body isn't standard in Mozilla Thunderbird anyway.  I'll
> have to try it under Outlook.
>
> Really would like for it to handle both.  Any other info anyone can
> provide would be appreciated.  I'm going to search the web for awhile
> and see what I can come up with.
>
>
> CMM wrote:
>> I don't think the "body" parameter of mailto: is standard... not sure
>> if its consistently implemented by all e-mail clients. I would hope in
>> today's day and age they all do.
>>
>> P.S.
>> System.Web.Mail is deprecated in .NET 2.0. For 2.0 users, the link
>> should be:
>> http://www.systemnetmail.com/ But in any case, the OP wants to trigger
>> the default E-mail program not worry about SMTP servers and stuff like
>> that.
>>
Author
2 May 2006 8:54 PM
cj
CMM,  I have it sending a message but I can't get it to start a message
and leave it on the screen.  The messages never show on the screen.

I also have been trying to figure out what the heck is going on with it
now as unlike "send to"/"mail recipient" this triggers Thunderbird to
tell me another application is trying to send mail from me.

I even had a problem to start with that my program launched internet
connection wizard to set up a new email account when I have two seperate
pop3 email accounts one in Thunderbird and one in Outlook which have
both been working for a year now.  Thunderbird is default.  I honestly
don't know why it disapeared but it did after I ran a program I
downloaded that was supposed to set different email programs as default.

CMM wrote:
Show quoteHide quote
> AKAIK, the easiest way to do this is using the classic MAPI32 ActiveX
> controls... yes it works with whatever e-mail is the default (both Outlook
> and OE and any E-mail client that follows Windows Standards)... and you can
> use it from .NET.
>
> http://activex.microsoft.com/controls/vb6/MSMAPI32.CAB
>
> Not sure if .NET 2.0 has the feature built-in.... but there should be no
> shame in using COM components in .NET if there no .NET alternative....
> Visual Studio IDE itself is a BIG *COM* application.
>
> Example that I think does what you ask once you add a reference to
> MSMAPI32.OCX:
>
> MAPISession1.DownLoadMail = False
> MAPISession1.SignOn
> MAPISession1.NewSession = True
>
> MAPIMessages1.SessionID = MAPISession1.SessionID
>
> MAPIMessages1.Compose
> MAPIMessages1.RecipAddress = "some***@somewhere.com"
> MAPIMessages1.msgSubject = "My subject"
> MAPIMessages1.msgNoteText = "bla bla bla"
>
> 'leave this out to keep the window open
> MAPIMessages1.Send
>
> MAPISession1.SignOff
> MAPISession1.NewSession = False
>
>
Author
2 May 2006 9:19 PM
CMM
MAPIMessages1.Send(True)
Should display the compose window.

--
-C. Moya
www.cmoya.com
Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:ejtvMqibGHA.4932@TK2MSFTNGP03.phx.gbl...
> CMM,  I have it sending a message but I can't get it to start a message
> and leave it on the screen.  The messages never show on the screen.
>
> I also have been trying to figure out what the heck is going on with it
> now as unlike "send to"/"mail recipient" this triggers Thunderbird to tell
> me another application is trying to send mail from me.
>
> I even had a problem to start with that my program launched internet
> connection wizard to set up a new email account when I have two seperate
> pop3 email accounts one in Thunderbird and one in Outlook which have both
> been working for a year now.  Thunderbird is default.  I honestly don't
> know why it disapeared but it did after I ran a program I downloaded that
> was supposed to set different email programs as default.
>
> CMM wrote:
>> AKAIK, the easiest way to do this is using the classic MAPI32 ActiveX
>> controls... yes it works with whatever e-mail is the default (both
>> Outlook and OE and any E-mail client that follows Windows Standards)...
>> and you can use it from .NET.
>>
>> http://activex.microsoft.com/controls/vb6/MSMAPI32.CAB
>>
>> Not sure if .NET 2.0 has the feature built-in.... but there should be no
>> shame in using COM components in .NET if there no .NET alternative....
>> Visual Studio IDE itself is a BIG *COM* application.
>>
>> Example that I think does what you ask once you add a reference to
>> MSMAPI32.OCX:
>>
>> MAPISession1.DownLoadMail = False
>> MAPISession1.SignOn
>> MAPISession1.NewSession = True
>>
>> MAPIMessages1.SessionID = MAPISession1.SessionID
>>
>> MAPIMessages1.Compose
>> MAPIMessages1.RecipAddress = "some***@somewhere.com"
>> MAPIMessages1.msgSubject = "My subject"
>> MAPIMessages1.msgNoteText = "bla bla bla"
>>
>> 'leave this out to keep the window open
>> MAPIMessages1.Send
>>
>> MAPISession1.SignOff
>> MAPISession1.NewSession = False
>>
Author
2 May 2006 9:28 PM
CMM
Also, MAPIMessages1.Send(True)
might fail unless you call
MAPIMessages1.ResolveName()
Right after setting the recipient
Sorry I left that out.

Also, re the Thunderbird thing.... yeah, this technique will probably
trigger Object Model guards.... it does so for Outlook and I don't why it
wouldn't do the same for Mozilla.



--
-C. Moya
www.cmoya.com
Show quoteHide quote
"CMM" <cmm@nospam.com> wrote in message
news:ORAnf4ibGHA.4604@TK2MSFTNGP02.phx.gbl...
> MAPIMessages1.Send(True)
> Should display the compose window.
>
> --
> -C. Moya
> www.cmoya.com
> "cj" <cj@nospam.nospam> wrote in message
> news:ejtvMqibGHA.4932@TK2MSFTNGP03.phx.gbl...
>> CMM,  I have it sending a message but I can't get it to start a message
>> and leave it on the screen.  The messages never show on the screen.
>>
>> I also have been trying to figure out what the heck is going on with it
>> now as unlike "send to"/"mail recipient" this triggers Thunderbird to
>> tell me another application is trying to send mail from me.
>>
>> I even had a problem to start with that my program launched internet
>> connection wizard to set up a new email account when I have two seperate
>> pop3 email accounts one in Thunderbird and one in Outlook which have both
>> been working for a year now.  Thunderbird is default.  I honestly don't
>> know why it disapeared but it did after I ran a program I downloaded that
>> was supposed to set different email programs as default.
>>
>> CMM wrote:
>>> AKAIK, the easiest way to do this is using the classic MAPI32 ActiveX
>>> controls... yes it works with whatever e-mail is the default (both
>>> Outlook and OE and any E-mail client that follows Windows Standards)...
>>> and you can use it from .NET.
>>>
>>> http://activex.microsoft.com/controls/vb6/MSMAPI32.CAB
>>>
>>> Not sure if .NET 2.0 has the feature built-in.... but there should be no
>>> shame in using COM components in .NET if there no .NET alternative....
>>> Visual Studio IDE itself is a BIG *COM* application.
>>>
>>> Example that I think does what you ask once you add a reference to
>>> MSMAPI32.OCX:
>>>
>>> MAPISession1.DownLoadMail = False
>>> MAPISession1.SignOn
>>> MAPISession1.NewSession = True
>>>
>>> MAPIMessages1.SessionID = MAPISession1.SessionID
>>>
>>> MAPIMessages1.Compose
>>> MAPIMessages1.RecipAddress = "some***@somewhere.com"
>>> MAPIMessages1.msgSubject = "My subject"
>>> MAPIMessages1.msgNoteText = "bla bla bla"
>>>
>>> 'leave this out to keep the window open
>>> MAPIMessages1.Send
>>>
>>> MAPISession1.SignOff
>>> MAPISession1.NewSession = False
>>>
>
Author
3 May 2006 1:09 PM
cj
Thanks CMM.  Now the inevitable follow ups.

1.  I'm dismayed that I can't find info on the syntax of the MAPI
commands.  For instance, when typing in MAPIMessages1.send(  it says it
takes "vDialog as object" but I have no idea what that means.  In vb
help I looked for mapi and only found mapimagecoordinates method so info
is not there.

2.  You had noted in your code to leave out MAPIMessages1.send to keep
the window open and in my mind MAPIMessages1.send would send the email
so it seemed obvious to me that if I didn't send it it would still be on
the screen waiting for me to send it.  So my focus on finding out how to
leave it on the screen was centered on signon or compose where I thought
maybe something had to be set to visible.  Anyway,
MAPIMessages1.send(true) works.  Even with signoff and newsession=false
still in the program.  I guess these lines are the program severing ties
with the message it just created and left on the screen?  Doesn't matter
it works.  Then again I'm just the kinda person who likes to know why.

3.  An interesting note.  When I tested MAPIMessages1.send(true) I was
not given the warning that another program was trying to send a message!
  But I am if I don't have the true in it.  So I'd assume it must only
warn if the message is actually being send w/o my knowledge.

Lastly just wanted to say that I am looking for the
MAPIMessages1.send(true) functionality and relieved it didn't cause any
warnings.  If it had caused a warning I was going to say Windows
Explorer's Send To / Mail Recipient doesn't cause warnings -- how'd they
do that.  But since it didn't this and that work the same and all's well.

Your pretty good at this.  Perhaps you'd care to make a brief comment on
system.web.mail (VS2003) and system.net.mail (VS2005).  I came across
them while working on this.  I'm not sure what exactly they are.  I
expect just other ways of doing the same thing w/o the com component.
I'm not planning to change to them now mind you.  Just still curious.
Do you know anything about them?

Again, Thank you.
cj


CMM wrote:
Show quoteHide quote
> Also, MAPIMessages1.Send(True)
> might fail unless you call
> MAPIMessages1.ResolveName()
> Right after setting the recipient
> Sorry I left that out.
>
> Also, re the Thunderbird thing.... yeah, this technique will probably
> trigger Object Model guards.... it does so for Outlook and I don't why it
> wouldn't do the same for Mozilla.
>
>
>
Author
3 May 2006 8:15 PM
CMM
Documentation for the MAPI ActiveX Control starts here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingmapicontrol.asp
Click "See Also" link for more detailed info.

Programs will choose how they react to being manipulated via MAPI. The
"warnings" are a function of the program and not MAPI per se. Outlook
complains whenever you set the RecipAddress property. Thunderbird may choose
not to complain until you do Send.

If you do not need to add attachments or get fancy with the Body.... mailto:
is probably the easiest solution for you.

P.S. .NET's built-in mail functionality is pretty good. It doesn't puppet an
e-mail client.. it actually does all the work, so you have to provide your
own UI. You can do this... as IE exposes its built-in HTML Editor (known
long long ago as FrontPage Express.... and now used by Outlook and Outlook
Express to compose messages) that you can plop on your forms fairly easily
(I can post more info if you'd like).

The older System.Web.Mail uses CDO under the hood to do all the work
(another set of objects installed by Outlook, Exchange, or IIS I think) that
may or may not be installed. I think the newer System.Net.Mail does 100% of
its own work.


--
-C. Moya
www.cmoya.com
Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:eaRKTLrbGHA.3712@TK2MSFTNGP03.phx.gbl...
> Thanks CMM.  Now the inevitable follow ups.
>
> 1.  I'm dismayed that I can't find info on the syntax of the MAPI
> commands.  For instance, when typing in MAPIMessages1.send(  it says it
> takes "vDialog as object" but I have no idea what that means.  In vb help
> I looked for mapi and only found mapimagecoordinates method so info is not
> there.
>
> 2.  You had noted in your code to leave out MAPIMessages1.send to keep the
> window open and in my mind MAPIMessages1.send would send the email so it
> seemed obvious to me that if I didn't send it it would still be on the
> screen waiting for me to send it.  So my focus on finding out how to leave
> it on the screen was centered on signon or compose where I thought maybe
> something had to be set to visible.  Anyway, MAPIMessages1.send(true)
> works.  Even with signoff and newsession=false still in the program.  I
> guess these lines are the program severing ties with the message it just
> created and left on the screen?  Doesn't matter it works.  Then again I'm
> just the kinda person who likes to know why.
>
> 3.  An interesting note.  When I tested MAPIMessages1.send(true) I was not
> given the warning that another program was trying to send a message! But I
> am if I don't have the true in it.  So I'd assume it must only warn if the
> message is actually being send w/o my knowledge.
>
> Lastly just wanted to say that I am looking for the
> MAPIMessages1.send(true) functionality and relieved it didn't cause any
> warnings.  If it had caused a warning I was going to say Windows
> Explorer's Send To / Mail Recipient doesn't cause warnings -- how'd they
> do that.  But since it didn't this and that work the same and all's well.
>
> Your pretty good at this.  Perhaps you'd care to make a brief comment on
> system.web.mail (VS2003) and system.net.mail (VS2005).  I came across them
> while working on this.  I'm not sure what exactly they are.  I expect just
> other ways of doing the same thing w/o the com component. I'm not planning
> to change to them now mind you.  Just still curious. Do you know anything
> about them?
>
> Again, Thank you.
> cj
>
>
> CMM wrote:
>> Also, MAPIMessages1.Send(True)
>> might fail unless you call
>> MAPIMessages1.ResolveName()
>> Right after setting the recipient
>> Sorry I left that out.
>>
>> Also, re the Thunderbird thing.... yeah, this technique will probably
>> trigger Object Model guards.... it does so for Outlook and I don't why it
>> wouldn't do the same for Mozilla.
>>
>>
Author
3 May 2006 8:35 PM
cj
I ended up getting a lot of work today so I didn't get far on this
project.  I'll look at the link--thanks.

Interesting to note but as I will not be adding recipaddress or sending
I should be ok.  It's an in house thing.

mailto is delightful but doesn't allow enough text to be put in the body
for me.  :(

I'll skip on the system.net.mail for now as I really prefer launching
the default email program.  I saw a conversation on this at another site
while doing research and I might be in the minority but I'd even prefer
web sites launch my email program than give me one of those web response
pages.  I never know where it's being sent and can't cc people or ask
for receipts.  I hate those web response forms.  Just give me an email
address and I'll write them.  This program is a windows app.

I'll skip system.web.mail too as there is no point in learning something
now that has already been replaced.



CMM wrote:
Show quoteHide quote
> Documentation for the MAPI ActiveX Control starts here:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconusingmapicontrol.asp
> Click "See Also" link for more detailed info.
>
> Programs will choose how they react to being manipulated via MAPI. The
> "warnings" are a function of the program and not MAPI per se. Outlook
> complains whenever you set the RecipAddress property. Thunderbird may choose
> not to complain until you do Send.
>
> If you do not need to add attachments or get fancy with the Body.... mailto:
> is probably the easiest solution for you.
>
> P.S. .NET's built-in mail functionality is pretty good. It doesn't puppet an
> e-mail client.. it actually does all the work, so you have to provide your
> own UI. You can do this... as IE exposes its built-in HTML Editor (known
> long long ago as FrontPage Express.... and now used by Outlook and Outlook
> Express to compose messages) that you can plop on your forms fairly easily
> (I can post more info if you'd like).
>
> The older System.Web.Mail uses CDO under the hood to do all the work
> (another set of objects installed by Outlook, Exchange, or IIS I think) that
> may or may not be installed. I think the newer System.Net.Mail does 100% of
> its own work.
>
>
Author
3 May 2006 1:32 PM
cj
Oh oh, I forgot.  When I added MAPIMessages1.ResolveName() the program
throws and exception "Unspecified Failure has occured".  So I left it
out.  It should be noted that my testing so far has only been with
Thunderbird.  I'll get to Outlook soon enough.  Thankfully for this
project I do not want to specify any recipients at all--that's why I
want the message left on the screen.



CMM wrote:
Show quoteHide quote
> Also, MAPIMessages1.Send(True)
> might fail unless you call
> MAPIMessages1.ResolveName()
> Right after setting the recipient
> Sorry I left that out.
>
> Also, re the Thunderbird thing.... yeah, this technique will probably
> trigger Object Model guards.... it does so for Outlook and I don't why it
> wouldn't do the same for Mozilla.
>
>
>
Author
3 May 2006 7:59 PM
CMM
Thunderbird may not support ResolveName()... which is why it throws the
exception. With Outlook, on my machine, if I try to do Send(True) without
calling that first I get an exception.

--
-C. Moya
www.cmoya.com
Show quoteHide quote
"cj" <cj@nospam.nospam> wrote in message
news:u5KCBYrbGHA.3856@TK2MSFTNGP03.phx.gbl...
> Oh oh, I forgot.  When I added MAPIMessages1.ResolveName() the program
> throws and exception "Unspecified Failure has occured".  So I left it out.
> It should be noted that my testing so far has only been with Thunderbird.
> I'll get to Outlook soon enough.  Thankfully for this project I do not
> want to specify any recipients at all--that's why I want the message left
> on the screen.
>
>
>
> CMM wrote:
>> Also, MAPIMessages1.Send(True)
>> might fail unless you call
>> MAPIMessages1.ResolveName()
>> Right after setting the recipient
>> Sorry I left that out.
>>
>> Also, re the Thunderbird thing.... yeah, this technique will probably
>> trigger Object Model guards.... it does so for Outlook and I don't why it
>> wouldn't do the same for Mozilla.
>>
>>