Home All Groups Group Topic Archive Search About

Emailing with default client

Author
18 Apr 2006 9:18 PM
Dustin Davis
(using VB.NET 2005)

I'm writing a desktop application that I would like to have the ability
to email files. I've set up the SMTP portion, now I would like to have a
MAPI option.

I found a MAPI tutorial, but it does a bit more than I want it to. What
I would like to do is this:

1. Open the default mail client's compose window.
2. Add an attachment

Then the user can fill out the To: Subject: etc.

Can anyone help me with this?

Thanks,
Dustin

Author
19 Apr 2006 5:29 AM
Cor Ligthert [MVP]
Dustin,

Your problem is in this sentence

> 2. Add an attachment

Not all emailclients have the possiblitity to add attachments. It is as well
not in the standard code for opening default email clients.

This question is thousand times done in this newsgroup. If you know that it
is Office Outlook than there are possibilites and I have read from Carlos
that it can as well at OutlookExpress, but not right from the box.

Cor
Author
19 Apr 2006 9:09 AM
Carlos J. Quintero [VB MVP]
Hi Dustin,

See if there is something here:

How do I send an email with attachments?
http://systemwebmail.com/faq/2.3.aspx

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com



Show quoteHide quote
"Dustin Davis" <dustin.da***@gmail.com> escribió en el mensaje
news:OuMRB3yYGHA.4688@TK2MSFTNGP04.phx.gbl...
> (using VB.NET 2005)
>
> I'm writing a desktop application that I would like to have the ability to
> email files. I've set up the SMTP portion, now I would like to have a MAPI
> option.
>
> I found a MAPI tutorial, but it does a bit more than I want it to. What I
> would like to do is this:
>
> 1. Open the default mail client's compose window.
> 2. Add an attachment
>
> Then the user can fill out the To: Subject: etc.
>
> Can anyone help me with this?
>
> Thanks,
> Dustin
Author
19 Apr 2006 10:51 AM
Cor Ligthert [MVP]
Carlos,

That is systemwebmail. A default client is opened in this way.
\\\
///a reference to System.Web
///using System.Web;
///using System.Diagnostic
Process.Start ("mailto:" + HttpUtility.UrlEncode("NotMyFirstN***@planet.nl")
+ "?subject=Does this helps" + "&body=How do you do?");
///

Cor

Show quoteHide quote
"Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> schreef in
bericht news:eAj7xD5YGHA.4424@TK2MSFTNGP05.phx.gbl...
> Hi Dustin,
>
> See if there is something here:
>
> How do I send an email with attachments?
> http://systemwebmail.com/faq/2.3.aspx
>
> --
>
> Best regards,
>
> Carlos J. Quintero
>
> MZ-Tools: Productivity add-ins for Visual Studio
> You can code, design and document much faster:
> http://www.mztools.com
>
>
>
> "Dustin Davis" <dustin.da***@gmail.com> escribió en el mensaje
> news:OuMRB3yYGHA.4688@TK2MSFTNGP04.phx.gbl...
>> (using VB.NET 2005)
>>
>> I'm writing a desktop application that I would like to have the ability
>> to email files. I've set up the SMTP portion, now I would like to have a
>> MAPI option.
>>
>> I found a MAPI tutorial, but it does a bit more than I want it to. What I
>> would like to do is this:
>>
>> 1. Open the default mail client's compose window.
>> 2. Add an attachment
>>
>> Then the user can fill out the To: Subject: etc.
>>
>> Can anyone help me with this?
>>
>> Thanks,
>> Dustin
>
>
Author
19 Apr 2006 2:44 PM
Dustin Davis
I've tried the mailto: method, but I can't seem to add an attachment.
I'm watching another program do the very thing I am trying to do, but I
don't know how it is doing it. It opens the default mail client compose
window with the specified file attached. Amazingly it works when I have
either Outlook Express or Thuderbird as my default mail client.

I've tried using the VB6 MAPI controls (MAPISession & MAPIMessages), I
can sent through Outlook Express, but not Thunderbird. When I send
through Outlook express it makes me enter my password twice - the fist
time is when it connects (it then wants to download all my new
messages), then again when I got to send. Frustrating :(

Cor Ligthert [MVP] wrote:
Show quoteHide quote
> Carlos,
>
> That is systemwebmail. A default client is opened in this way.
> \\\
>  ///a reference to System.Web
> ///using System.Web;
> ///using System.Diagnostic
> Process.Start ("mailto:" + HttpUtility.UrlEncode("NotMyFirstN***@planet.nl")
>  + "?subject=Does this helps" + "&body=How do you do?");
> ///
>
> Cor
>
> "Carlos J. Quintero [VB MVP]" <carlosq@NOSPAMsogecable.com> schreef in
> bericht news:eAj7xD5YGHA.4424@TK2MSFTNGP05.phx.gbl...
>> Hi Dustin,
>>
>> See if there is something here:
>>
>> How do I send an email with attachments?
>> http://systemwebmail.com/faq/2.3.aspx
>>
>> --
>>
>> Best regards,
>>
>> Carlos J. Quintero
>>
>> MZ-Tools: Productivity add-ins for Visual Studio
>> You can code, design and document much faster:
>> http://www.mztools.com
>>
>>
>>
>> "Dustin Davis" <dustin.da***@gmail.com> escribió en el mensaje
>> news:OuMRB3yYGHA.4688@TK2MSFTNGP04.phx.gbl...
>>> (using VB.NET 2005)
>>>
>>> I'm writing a desktop application that I would like to have the ability
>>> to email files. I've set up the SMTP portion, now I would like to have a
>>> MAPI option.
>>>
>>> I found a MAPI tutorial, but it does a bit more than I want it to. What I
>>> would like to do is this:
>>>
>>> 1. Open the default mail client's compose window.
>>> 2. Add an attachment
>>>
>>> Then the user can fill out the To: Subject: etc.
>>>
>>> Can anyone help me with this?
>>>
>>> Thanks,
>>> Dustin
>>
>
>
Author
19 Apr 2006 3:23 PM
Carlos J. Quintero [VB MVP]
Ah, yes, but anyway an approach would be to use SystemWebMail and provide
your own compose form with subject, destination textboxes and attach button
since I don´t think that Simple MAPI will be able to add attachments, so
either you need to use Extended MAPI (C++), not .NET compatible, or use CDO,
which may not work for all e-mail clients.

See:

Differences between CDO, Simple MAPI, and Extended MAPI
http://support.microsoft.com/kb/200018/en-us


--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com


Show quoteHide quote
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> escribió en el mensaje
news:eEdno75YGHA.3424@TK2MSFTNGP02.phx.gbl...
> Carlos,
>
> That is systemwebmail. A default client is opened in this way.
> \\\
> ///a reference to System.Web
> ///using System.Web;
> ///using System.Diagnostic
> Process.Start ("mailto:" +
> HttpUtility.UrlEncode("NotMyFirstN***@planet.nl")
> + "?subject=Does this helps" + "&body=How do you do?");
> ///
>
Author
19 Apr 2006 4:04 PM
Dustin Davis
So, in any case, I got it to work as I needed using the VB6 MAPI
controls. Without going into too much detail, I'll just post the
function here in case anyone else is interested. Let me know if you have
question on what I did here (This works in Mozilla Thunderbird and
Outlook Express):

Private Function SendMapiEmail() As Boolean
     Dim FilePaths() As String = IO.Directory.GetFiles(Me.TempOutputPath)

     Try
         With Me.MapiSession
             If .SessionID = 0 Then
                 .DownLoadMail = False
                 .LogonUI = True
                 .SignOn()
             End If
         End With

         With Me.MapiMessages
             .SessionID = Me.MapiSession.SessionID
             .Compose()
             .MsgSubject = "Images Attached"
             .MsgNoteText = "(See Attached)"
             For i As Integer = 0 To FilePaths.Length - 1
                 .AttachmentIndex = i
                 .AttachmentPathName = FilePaths(i)
             Next
             .Send(True)
         End With
         Me.MapiSession.SignOff()
     Catch ex As Exception
         MsgBox("Error sending MAPI email: " & ex.Message,
MsgBoxStyle.Exclamation, AppName)
         Return False
     End Try

     Return True
End Function

Carlos J. Quintero [VB MVP] wrote:
Show quoteHide quote
> Ah, yes, but anyway an approach would be to use SystemWebMail and provide
> your own compose form with subject, destination textboxes and attach button
> since I don´t think that Simple MAPI will be able to add attachments, so
> either you need to use Extended MAPI (C++), not .NET compatible, or use CDO,
> which may not work for all e-mail clients.
>
> See:
>
> Differences between CDO, Simple MAPI, and Extended MAPI
> http://support.microsoft.com/kb/200018/en-us
>
>
Author
19 Apr 2006 11:17 PM
Dennis
What .dll did you have to reference to use VB6Mapi?
--
Dennis in Houston


Show quoteHide quote
"Dustin Davis" wrote:

> So, in any case, I got it to work as I needed using the VB6 MAPI
> controls. Without going into too much detail, I'll just post the
> function here in case anyone else is interested. Let me know if you have
> question on what I did here (This works in Mozilla Thunderbird and
> Outlook Express):
>
> Private Function SendMapiEmail() As Boolean
>      Dim FilePaths() As String = IO.Directory.GetFiles(Me.TempOutputPath)
>
>      Try
>          With Me.MapiSession
>              If .SessionID = 0 Then
>                  .DownLoadMail = False
>                  .LogonUI = True
>                  .SignOn()
>              End If
>          End With
>
>          With Me.MapiMessages
>              .SessionID = Me.MapiSession.SessionID
>              .Compose()
>              .MsgSubject = "Images Attached"
>              .MsgNoteText = "(See Attached)"
>              For i As Integer = 0 To FilePaths.Length - 1
>                  .AttachmentIndex = i
>                  .AttachmentPathName = FilePaths(i)
>              Next
>              .Send(True)
>          End With
>          Me.MapiSession.SignOff()
>      Catch ex As Exception
>          MsgBox("Error sending MAPI email: " & ex.Message,
> MsgBoxStyle.Exclamation, AppName)
>          Return False
>      End Try
>
>      Return True
> End Function
>
> Carlos J. Quintero [VB MVP] wrote:
> > Ah, yes, but anyway an approach would be to use SystemWebMail and provide
> > your own compose form with subject, destination textboxes and attach button
> > since I don´t think that Simple MAPI will be able to add attachments, so
> > either you need to use Extended MAPI (C++), not .NET compatible, or use CDO,
> > which may not work for all e-mail clients.
> >
> > See:
> >
> > Differences between CDO, Simple MAPI, and Extended MAPI
> > http://support.microsoft.com/kb/200018/en-us
> >
> >
>
Author
20 Apr 2006 4:12 PM
Dustin Davis
Here's the steps you should follow to get the code to work that I posted
previously:

1. Add a reference to the COM "Microsoft MAPI Controls 6.0"
2. In your Toolbox, right-click and select "Choose items..."
3. In the COM Components tab, select the "Microsoft MAPI Messages
Control" and the "Microsoft MAPI Session Control"
4. Add the controls to your form

Dennis wrote:
Show quoteHide quote
> What .dll did you have to reference to use VB6Mapi?
Author
20 Apr 2006 11:13 PM
Dennis
I don't have VB6 installed on my computer and don't want to install it
really.  Can I get the controls and just add them to the bin directory?  If
so, where can I find them>
--
Dennis in Houston


Show quoteHide quote
"Dustin Davis" wrote:

> Here's the steps you should follow to get the code to work that I posted
> previously:
>
> 1. Add a reference to the COM "Microsoft MAPI Controls 6.0"
> 2. In your Toolbox, right-click and select "Choose items..."
> 3. In the COM Components tab, select the "Microsoft MAPI Messages
> Control" and the "Microsoft MAPI Session Control"
> 4. Add the controls to your form
>
> Dennis wrote:
> > What .dll did you have to reference to use VB6Mapi?
>
Author
21 Apr 2006 2:43 PM
Dustin Davis
I'm not sure. I don't have vb6 installed either. VB.NET 2005 is the only
version I have ever installed on my machine.

Dennis wrote:
Show quoteHide quote
> I don't have VB6 installed on my computer and don't want to install it
> really.  Can I get the controls and just add them to the bin directory?  If
> so, where can I find them>
Author
20 Apr 2006 9:32 AM
Carlos J. Quintero [VB MVP]
So the MAPI controls allow to send attachments. Did you investigate of the
Simple MAPI allow that? They are 12 API functions or so and if it works it
would allow you to get rid of the VB6 controls in your app...

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com




Show quoteHide quote
"Dustin Davis" <dustin.da***@gmail.com> escribió en el mensaje
news:OFuWjs8YGHA.3532@TK2MSFTNGP05.phx.gbl...
> So, in any case, I got it to work as I needed using the VB6 MAPI controls.
> Without going into too much detail, I'll just post the function here in
> case anyone else is interested. Let me know if you have question on what I
> did here (This works in Mozilla Thunderbird and Outlook Express):
>
> Private Function SendMapiEmail() As Boolean
>     Dim FilePaths() As String = IO.Directory.GetFiles(Me.TempOutputPath)
>
>     Try
>         With Me.MapiSession
>             If .SessionID = 0 Then
>                 .DownLoadMail = False
>                 .LogonUI = True
>                 .SignOn()
>             End If
>         End With
>
>         With Me.MapiMessages
>             .SessionID = Me.MapiSession.SessionID
>             .Compose()
>             .MsgSubject = "Images Attached"
>             .MsgNoteText = "(See Attached)"
>             For i As Integer = 0 To FilePaths.Length - 1
>                 .AttachmentIndex = i
>                 .AttachmentPathName = FilePaths(i)
>             Next
>             .Send(True)
>         End With
>         Me.MapiSession.SignOff()
>     Catch ex As Exception
>         MsgBox("Error sending MAPI email: " & ex.Message,
> MsgBoxStyle.Exclamation, AppName)
>         Return False
>     End Try
>
>     Return True
> End Function
>