Starting default mail program

J

Jack Russell

I have the following code

Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
'To use this code you need to add a reference to System.web!!!
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub

I am sure this workewd under VB 2003/ .net framework 1.1 but it throws
an error
"the ordinal 36 could not be located in the dynamic link library
MAPI32.dll."

I have googling etc with no success.

Thanks

Jack Russell
 
C

Cor Ligthert[MVP]

Jack,

Will you tell us where it is not working, maybe we can then help you to find
the solution for this problem?

(In my idea is this from a sample as Herfried and I often have used).

Cor
 
H

Herfried K. Wagner [MVP]

Jack Russell said:
Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
'To use this code you need to add a reference to System.web!!!
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub

I am sure this workewd under VB 2003/ .net framework 1.1 but it throws an
error
"the ordinal 36 could not be located in the dynamic link library
MAPI32.dll."

What's the system's default mail client? Does the error message appear too
if you remove the calls to 'HttpUtility.UrlEncode'?
 
M

Michel Posseth [MCP]

The method works flawless here under VS 2005 ,

I guess your MAPI32.dll has gone corupted

regards

Michel
 
J

Jack Russell

Thanks, that was it, now I am worried how it happened!

The method works flawless here under VS 2005 ,

I guess your MAPI32.dll has gone corupted

regards

Michel



I have the following code

Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
'To use this code you need to add a reference to System.web!!!
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub

I am sure this workewd under VB 2003/ .net framework 1.1 but it throws an
error
"the ordinal 36 could not be located in the dynamic link library
MAPI32.dll."

I have googling etc with no success.

Thanks

Jack Russell
 
M

Michel Posseth [MCP]

Well ,,,,

mapi32.dll is usually installed with Outlook with MS Office or Microsoft
Exchange tools.

As you can see here
http://support.microsoft.com/dllhelp/?dlltype=file&l=55&alpha=mapi32.dll&S=1&x=14&y=5
there are lots of versions of this dll
so it might also be a dependency of a legacy piece of software that you
installed ( win 32 progs ) that corupted your version

Or maybe just maybe ,,, some bits and bytes on your harddisk were living
there own life on your HD :)

regards
Michel

Jack Russell said:
Thanks, that was it, now I am worried how it happened!

The method works flawless here under VS 2005 ,

I guess your MAPI32.dll has gone corupted

regards

Michel



I have the following code

Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
'To use this code you need to add a reference to System.web!!!
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub

I am sure this workewd under VB 2003/ .net framework 1.1 but it throws an
error
"the ordinal 36 could not be located in the dynamic link library
MAPI32.dll."

I have googling etc with no success.

Thanks

Jack Russell
 
R

rowe_newsgroups

I have the following code

Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
'To use this code you need to add a reference to System.web!!!
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub

I am sure this workewd under VB 2003/ .net framework 1.1 but it throws
an error
"the ordinal 36 could not be located in the dynamic link library
MAPI32.dll."

I have googling etc with no success.

Thanks

Jack Russell

Please note that the subject and body tags are not "officially"
supported members of the mailto tag. For that reason you shouldn't
rely on them for critical components.

Thanks,

Seth Rowe
 
C

Cor Ligthert[MVP]

Michel,

Now you show this, it has probably nothing to do with the mail part to get
the default client.

It has most probably to do with a corrupted default client.

If the OP would change his default client, it probably will work.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top