SMTP Email in VB2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?T3N2YWxkbyBSb3Nhcmlv?=

    #1

    SMTP Email in VB2005

    I'm using SMTP for email in a VB2005 application. The problem is that the
    email is sent when I exit the application, not at the moment that the
    client.Send command is generated.

    There's a setting to done to allow the email to be sent at real time?

    Thanks a lot.
  • Charlie Brown

    #2
    Re: SMTP Email in VB2005

    SMTP will send the mail when your application directs it to. There is
    no setting, the defaults will work for the most part. Post your
    sending code.

    Comment

    • =?Utf-8?B?T3N2YWxkbyBSb3Nhcmlv?=

      #3
      Re: SMTP Email in VB2005

      Here is the code:

      Dim sb As New StringBuilder()

      sb.Append("The following email was sent to you from WRDCS " & _
      "(Warehouse ). Please do not reply.")
      sb.Append(vbCrL f)
      sb.Append(vbCrL f)

      sb.Append("Disc repancy in Item: " & Me.txtItem.Text )
      sb.Append(vbCrL f)
      sb.Append(vbCrL f)
      sb.Append("SF: " & vbTab & vbTab & vbTab & Me.txtSF.Text)
      sb.Append(vbCrL f)
      sb.Append("Repo rted Weight: " & vbTab & Me.txtNet.Text)
      sb.Append(vbCrL f)
      sb.Append("Scal ed Weight: " & vbTab & vbTab & tmpScaleGrossWe ight)
      sb.Append(vbCrL f)


      Dim mMailMessage As New MailMessage()
      Dim client As New SmtpClient(strE mailServer)

      mMailMessage.Fr om = New MailAddress("WR DCS@wrdcs.com")
      mMailMessage.To .Add(New MailAddress(str EmailRecipient) )

      mMailMessage.Su bject = "Discrepanc y"
      mMailMessage.Bo dy = sb.ToString
      mMailMessage.Is BodyHtml = False
      mMailMessage.Pr iority = MailPriority.No rmal

      client.Send(mMa ilMessage)

      mMailMessage.Di spose()

      Thanks a lot

      "Charlie Brown" wrote:
      SMTP will send the mail when your application directs it to. There is
      no setting, the defaults will work for the most part. Post your
      sending code.
      >
      >

      Comment

      • Bugs

        #4
        Re: SMTP Email in VB2005

        I've noticed the same behavior as well when I was experimenting with the
        SmtpClient class. Have you found a solution? Waiting until the
        application exits before the messages are sent is unacceptable.
        Thanks!

        Comment

        • Bruce W. Darby

          #5
          Re: SMTP Email in VB2005

          Osvaldo,

          I found this little piece of code for sending an SMTP email message...



          The only difference I see in the code you provided and the code at the above
          link is the Host address, but you can go through the code yourself and see
          if there is something that would work for your application. If it still
          doesn't send immediately, it could be something in your Exchange server that
          is preventing the email from sending immediately.

          Bruce W. Darby

          "Osvaldo Rosario" <OsvaldoRosario @discussions.mi crosoft.comwrot e in
          message news:C1C0AAAE-9FB7-40AF-A3F6-8C964FD143A2@mi crosoft.com...
          I'm using SMTP for email in a VB2005 application. The problem is that the
          email is sent when I exit the application, not at the moment that the
          client.Send command is generated.
          >
          There's a setting to done to allow the email to be sent at real time?
          >
          Thanks a lot.

          Comment

          • Charlie Brown

            #6
            Re: SMTP Email in VB2005

            Try adding credentials

            client.Credenti als = New Net.NetworkCred ential(Me.MailS erverUserName,
            Me.MailServerPa ssword)

            and you might want to try removing the call to dispose

            Comment

            Working...