Starting default mail program

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jack Russell

    #1

    Starting default mail program

    I have the following code

    Public Sub StartDefaultMai l( _
    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 ProcessStartInf o
    psi.UseShellExe cute = True
    psi.FileName = _
    "mailto:" & HttpUtility.Url Encode([To]) & _
    "?subject=" & HttpUtility.Url Encode(Subject) & _
    "&body=" & HttpUtility.Url Encode(Message)
    Process.Start(p si)
    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

  • Cor Ligthert[MVP]

    #2
    Re: Starting default mail program

    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

    Comment

    • Michel Posseth [MCP]

      #3
      Re: Starting default mail program

      The method works flawless here under VS 2005 ,

      I guess your MAPI32.dll has gone corupted

      regards

      Michel



      "Jack Russell" <jackr@norubbis h.tpg.com.ausch reef in bericht
      news:Oux34vBJIH A.1620@TK2MSFTN GP03.phx.gbl...
      >I have the following code
      >
      Public Sub StartDefaultMai l( _
      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 ProcessStartInf o
      psi.UseShellExe cute = True
      psi.FileName = _
      "mailto:" & HttpUtility.Url Encode([To]) & _
      "?subject=" & HttpUtility.Url Encode(Subject) & _
      "&body=" & HttpUtility.Url Encode(Message)
      Process.Start(p si)
      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
      >

      Comment

      • Jack Russell

        #4
        Re: Starting default mail program

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


        Michel Posseth [MCP] wrote:
        The method works flawless here under VS 2005 ,
        >
        I guess your MAPI32.dll has gone corupted
        >
        regards
        >
        Michel
        >
        >
        >
        "Jack Russell" <jackr@norubbis h.tpg.com.ausch reef in bericht
        news:Oux34vBJIH A.1620@TK2MSFTN GP03.phx.gbl...
        >
        >>I have the following code
        >>
        > Public Sub StartDefaultMai l( _
        > 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 ProcessStartInf o
        > psi.UseShellExe cute = True
        > psi.FileName = _
        > "mailto:" & HttpUtility.Url Encode([To]) & _
        > "?subject=" & HttpUtility.Url Encode(Subject) & _
        > "&body=" & HttpUtility.Url Encode(Message)
        > Process.Start(p si)
        > 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
        >>
        >
        >
        >

        Comment

        • Michel Posseth [MCP]

          #5
          Re: Starting default mail program

          Well ,,,,

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

          As you can see here

          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" <jackr@norubbis h.tpg.com.ausch reef in bericht
          news:%23I7Bf8JJ IHA.5116@TK2MSF TNGP03.phx.gbl. ..
          Thanks, that was it, now I am worried how it happened!
          >
          >
          Michel Posseth [MCP] wrote:
          >The method works flawless here under VS 2005 ,
          >>
          >I guess your MAPI32.dll has gone corupted
          >>
          >regards
          >>
          >Michel
          >>
          >>
          >>
          >"Jack Russell" <jackr@norubbis h.tpg.com.ausch reef in bericht
          >news:Oux34vBJI HA.1620@TK2MSFT NGP03.phx.gbl.. .
          >>
          >>>I have the following code
          >>>
          >> Public Sub StartDefaultMai l( _
          >> 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 ProcessStartInf o
          >> psi.UseShellExe cute = True
          >> psi.FileName = _
          >> "mailto:" & HttpUtility.Url Encode([To]) & _
          >> "?subject=" & HttpUtility.Url Encode(Subject) & _
          >> "&body=" & HttpUtility.Url Encode(Message)
          >> Process.Start(p si)
          >> 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
          >>>
          >>
          >>

          Comment

          • rowe_newsgroups

            #6
            Re: Starting default mail program

            On Nov 10, 11:32 pm, Jack Russell <ja...@norubbis h.tpg.com.auwro te:
            I have the following code
            >
            Public Sub StartDefaultMai l( _
            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 ProcessStartInf o
            psi.UseShellExe cute = True
            psi.FileName = _
            "mailto:" & HttpUtility.Url Encode([To]) & _
            "?subject=" & HttpUtility.Url Encode(Subject) & _
            "&body=" & HttpUtility.Url Encode(Message)
            Process.Start(p si)
            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

            Comment

            • Cor Ligthert[MVP]

              #7
              Re: Starting default mail program

              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

              Comment

              Working...