Invoke standard mail client

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Lafrowda

    Invoke standard mail client

    Hello experts,

    I'm coding a routine which should open a new mail form of the mail standard
    mail client installed on a system (e.g. outlook, outlook express, netscape
    mail, etc.) for support reasons. The routine should fill in some textual
    information. It should, however, not mail the information directly. The user
    should be able to check the contents of the mail and he should be able to
    edit the mail before sending it.
    Consequently, I have the simple question: Is there any method in visual
    basic (.net) to force the standard mail client of a machine to open a new
    form (like mailto:... in HTML) and fill in some information?

    Best regards,

    John


  • Vicky

    #2
    Re: Invoke standard mail client

    You can use shellexecute api call and pass mailto:youremai lid@xyz.com in the
    lpfile paramater.

    Vikram


    "John Lafrowda" <laa.laa@laa.co m> wrote in message
    news:bvf9f8$3pd $1@news.uni-stuttgart.de...[color=blue]
    > Hello experts,
    >
    > I'm coding a routine which should open a new mail form of the mail[/color]
    standard[color=blue]
    > mail client installed on a system (e.g. outlook, outlook express, netscape
    > mail, etc.) for support reasons. The routine should fill in some textual
    > information. It should, however, not mail the information directly. The[/color]
    user[color=blue]
    > should be able to check the contents of the mail and he should be able to
    > edit the mail before sending it.
    > Consequently, I have the simple question: Is there any method in visual
    > basic (.net) to force the standard mail client of a machine to open a new
    > form (like mailto:... in HTML) and fill in some information?
    >
    > Best regards,
    >
    > John
    >
    >[/color]


    Comment

    • Cor

      #3
      Re: Invoke standard mail client

      Hi John,

      Not only one more, the most simple one I think is the one I have pasted in
      bellow.
      When you paste it in your IDE it looks nice again. :-)
      It is really easy but complete and therefore it looks now maybe complex.

      \\\by Fergus Cooney & small corrections by Cor
      'A reference to System.Web may be necessary
      'in the Project for this Import to work.
      Imports System.Web.Http Utility

      Public Sub StartDefaultMai l (sTo As String, _
      Optional sSubject As String = "", _
      Optional sMessage As String = "")
      Try
      sTo = UrlEncode (sTo)
      sSubject = sSubject
      sMessage = sMessage
      Process.Start ("mailto:" & sTo & "?subject=" _
      & sSubject & "&body=" & sMessage)

      Catch e As Exception
      MsgBox ("Couldn't start default email application" _
      & vbCrLf & e.Message)
      'or
      Throw New Exception ("Couldn't start default email app", e)
      End Try
      End Sub
      ///

      I hope this helps a little bit?

      Cor

      [color=blue]
      > I'm coding a routine which should open a new mail form of the mail[/color]
      standard[color=blue]
      > mail client installed on a system (e.g. outlook, outlook express, netscape
      > mail, etc.) for support reasons. The routine should fill in some textual
      > information. It should, however, not mail the information directly. The[/color]
      user[color=blue]
      > should be able to check the contents of the mail and he should be able to
      > edit the mail before sending it.
      > Consequently, I have the simple question: Is there any method in visual
      > basic (.net) to force the standard mail client of a machine to open a new
      > form (like mailto:... in HTML) and fill in some information?[/color]


      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Invoke standard mail client

        * "Cor" <non@non.com> scripsit:[color=blue]
        > \\\by Fergus Cooney & small corrections by Cor
        > 'A reference to System.Web may be necessary
        > 'in the Project for this Import to work.
        > Imports System.Web.Http Utility
        >
        > Public Sub StartDefaultMai l (sTo As String, _
        > Optional sSubject As String = "", _
        > Optional sMessage As String = "")
        > Try
        > sTo = UrlEncode (sTo)
        > sSubject = sSubject
        > sMessage = sMessage
        > Process.Start ("mailto:" & sTo & "?subject=" _
        > & sSubject & "&body=" & sMessage)
        >
        > Catch e As Exception
        > MsgBox ("Couldn't start default email application" _
        > & vbCrLf & e.Message)
        > 'or
        > Throw New Exception ("Couldn't start default email app", e)
        > End Try
        > End Sub
        > ///[/color]

        Why did the code loose all indentations?

        --
        Herfried K. Wagner [MVP]
        <http://www.mvps.org/dotnet>

        Comment

        • Cor

          #5
          Re: Invoke standard mail client

          >Why did the code loose all indentations?

          Because I have made my HKW database with a function to do that for me.

          :-)

          But Fergus also said it was not nice looking what is your opinion?

          Cor



          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Invoke standard mail client

            Cor,

            * "Cor" <non@non.com> scripsit:[color=blue][color=green]
            >> Why did the code loose all indentations?[/color]
            >
            > Because I have made my HKW database with a function to do that for me.
            >
            > :-)
            >
            > But Fergus also said it was not nice looking what is your opinion?[/color]

            Mhm... I prefer indented code even in newsgroup posts because it makes
            reading the code much easier. Just a thought.

            --
            Herfried K. Wagner [MVP]
            <http://www.mvps.org/dotnet>

            Comment

            • Cor

              #7
              Re: Invoke standard mail client

              Will be changed,

              Herr Herfried
              Sir Fergus

              :-))

              Cor[color=blue]
              >[color=green]
              > > But Fergus also said it was not nice looking what is your opinion?[/color]
              >
              > Mhm... I prefer indented code even in newsgroup posts because it makes
              > reading the code much easier. Just a thought.[/color]


              Comment

              • Herfried K. Wagner [MVP]

                #8
                OT: Re: Invoke standard mail client

                Cor,

                * "Cor" <non@non.com> scripsit:[color=blue]
                > Will be changed,
                >
                > Herr Herfried
                > Sir Fergus
                >
                > :-))[/color]

                :-)

                --
                Herfried K. Wagner [MVP]
                <http://www.mvps.org/dotnet>

                Comment

                • John Lafrowda

                  #9
                  Re: Invoke standard mail client

                  Thanks for all the replies.
                  Process.Start(" mailto:...") seems to be the easiest solution.

                  Cheers,

                  John


                  "John Lafrowda" <laa.laa@laa.co m> schrieb im Newsbeitrag
                  news:bvf9f8$3pd $1@news.uni-stuttgart.de...[color=blue]
                  > Hello experts,
                  >
                  > I'm coding a routine which should open a new mail form of the mail[/color]
                  standard[color=blue]
                  > mail client installed on a system (e.g. outlook, outlook express, netscape
                  > mail, etc.) for support reasons. The routine should fill in some textual
                  > information. It should, however, not mail the information directly. The[/color]
                  user[color=blue]
                  > should be able to check the contents of the mail and he should be able to
                  > edit the mail before sending it.
                  > Consequently, I have the simple question: Is there any method in visual
                  > basic (.net) to force the standard mail client of a machine to open a new
                  > form (like mailto:... in HTML) and fill in some information?
                  >
                  > Best regards,
                  >
                  > John
                  >
                  >[/color]


                  Comment

                  • gmarques

                    #10
                    Re: Invoke standard mail client


                    Public Sub StartDefaultMai l(ByVal [To] As String, Optional ByVal Subject
                    As String = "", Optional ByVal Message As String = "")


                    Try
                    Dim psi As New ProcessStartInf o

                    psi.UseShellExe cute = True
                    'psi.UseShellEx ecute = False

                    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(ex.Me ssage, ex)
                    End Try
                    End Sub

                    i'm using this function,and it works! my question is:
                    is it possible to get more information from the outlook template, like
                    the mail server?
                    very important!
                    thank you



                    --
                    gmarques
                    ------------------------------------------------------------------------
                    Posted via http://www.mcse.ms
                    ------------------------------------------------------------------------
                    View this thread: http://www.mcse.ms/message348338.html

                    Comment

                    Working...