Introduction and Sending Email Question

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

    #1

    Introduction and Sending Email Question


    Hello,

    I'd like to introduce myself.I have done zero programming since the
    days of GWBasic in college. I began using VB.Net 2005 around a month
    ago, and even though I've had no formal training, I've found it very
    easy to use by looking up docs and examples online, as well as having
    found the answers to many of my questions by browsing here. Thanks to
    all here! I'm quite sure that my code is not pretty, but it seems to
    do the job.

    That being said, I have a problem for which I have yet to find a
    solution. The follow sub works fine for sending emails from my app,
    with the exception that the email is sometimes not sent for two or
    three minutes, and in some instances not until another is sent or I
    close the app.

    Is there a way to "flush" the email cue, or otherwise force the emails
    to be sent immediately after this sub is called?

    Thanks,

    SFS


    Sub MailIt(from As String, recipient As String, _
    subject As String, body As String, login As String, _
    password As String)

    Dim mMailMessage As New MailMessage()
    Dim client As New SmtpClient("smt p.myhost.com")

    client.Credenti als = New System.Net.Netw orkCredential _
    (login, password)
    mMailMessage.Fr om = New MailAddress(fro m)
    mMailMessage.To .Add(New MailAddress(rec ipient))

    mMailMessage.Su bject = subject
    mMailMessage.Bo dy = body
    mMailMessage.Is BodyHtml = False
    mMailMessage.Pr iority = MailPriority.No rmal

    client.Send(mMa ilMessage)

    End Sub
  • Spam Catcher

    #2
    Re: Introduction and Sending Email Question

    SFS <sfs409@yahoo.c omwrote in news:4boms2hppc 1vk2eru0r553llo cfct6th46@
    4ax.com:
    Is there a way to "flush" the email cue, or otherwise force the emails
    to be sent immediately after this sub is called?
    ..Send sends the e-mail off to your mail server.

    If there are any delays, it might be your local mail server or the remote
    mail server... or anything in between ;-)

    Comment

    • ShaneO

      #3
      Re: Introduction and Sending Email Question

      SFS wrote:
      >
      Is there a way to "flush" the email cue, or otherwise force the emails
      to be sent immediately after this sub is called?
      >
      A few days ago I provided the following reply to someone else with
      exactly the same question (modified for your code) -

      *************** ***
      I believe the answer to the Delay problem revolves around the Garbage
      Collection of the Mail Message. (I haven't had a problem with this so I
      can't be certain).

      Try doing the following after your "client.Send(mM ailMessage)" line -

      mMailMessage.Di spose

      If you then find a problem that your Message seems to just vanish (ie.
      never gets sent) then do it this way -

      System.Threadin g.Thread.Sleep( 100)
      mMailMessage.Di spose

      Please post back your results so myself (and others) can be aware of
      these matters in the future.
      *************** ***

      ShaneO

      There are 10 kinds of people - Those who understand Binary and those who
      don't.

      Comment

      • SFS

        #4
        Re: Introduction and Sending Email Question

        On Fri, 09 Feb 2007 06:28:22 +1000, ShaneO <spcacc@optusne t.com.au>
        wrote:
        >SFS wrote:
        >>
        >Is there a way to "flush" the email cue, or otherwise force the emails
        >to be sent immediately after this sub is called?
        >>
        <snip>
        >Try doing the following after your "client.Send(mM ailMessage)" line -
        >
        >mMailMessage.D ispose
        >
        >If you then find a problem that your Message seems to just vanish (ie.
        >never gets sent) then do it this way -
        >
        >System.Threadi ng.Thread.Sleep (100)
        >mMailMessage.D ispose
        >
        Thanks, ShaneO. mMailMessage.Di spose (without the sleep) seems to
        have fixed the problem.

        SFS

        Comment

        • susiedba@hotmail.com

          #5
          Re: Introduction and Sending Email Question


          hey dipshit

          no matter what you do; do NOT put your marbles in the MS camp

          MS does not give a shit about programmers; they have demonstrated this
          time and time again


          maybe they'll invent L## next month and stop giving a crap about all
          this dotnet crap

          SERIOUSLY

          ms betrayed us all, move to PHP or get shafted eventually



          On Feb 8, 9:58 am, SFS <sfs...@yahoo.c omwrote:
          Hello,
          >
          I'd like to introduce myself.I have done zero programming since the
          days of GWBasic in college. I began using VB.Net 2005 around a month
          ago, and even though I've had no formal training, I've found it very
          easy to use by looking up docs and examples online, as well as having
          found the answers to many of my questions by browsing here. Thanks to
          all here! I'm quite sure that my code is not pretty, but it seems to
          do the job.
          >
          That being said, I have a problem for which I have yet to find a
          solution. The follow sub works fine for sending emails from my app,
          with the exception that the email is sometimes not sent for two or
          three minutes, and in some instances not until another is sent or I
          close the app.
          >
          Is there a way to "flush" the email cue, or otherwise force the emails
          to be sent immediately after this sub is called?
          >
          Thanks,
          >
          SFS
          >
          Sub MailIt(from As String, recipient As String, _
          subject As String, body As String, login As String, _
          password As String)
          >
          Dim mMailMessage As New MailMessage()
          Dim client As New SmtpClient("smt p.myhost.com")
          >
          client.Credenti als = New System.Net.Netw orkCredential _
          (login, password)
          mMailMessage.Fr om = New MailAddress(fro m)
          mMailMessage.To .Add(New MailAddress(rec ipient))
          >
          mMailMessage.Su bject = subject
          mMailMessage.Bo dy = body
          mMailMessage.Is BodyHtml = False
          mMailMessage.Pr iority = MailPriority.No rmal
          >
          client.Send(mMa ilMessage)
          >
          End Sub

          Comment

          Working...