473,395 Members | 1,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Mar 8 '07 #1
5 1191
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.

Mar 8 '07 #2
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(vbCrLf)
sb.Append(vbCrLf)

sb.Append("Discrepancy in Item: " & Me.txtItem.Text)
sb.Append(vbCrLf)
sb.Append(vbCrLf)
sb.Append("SF: " & vbTab & vbTab & vbTab & Me.txtSF.Text)
sb.Append(vbCrLf)
sb.Append("Reported Weight: " & vbTab & Me.txtNet.Text)
sb.Append(vbCrLf)
sb.Append("Scaled Weight: " & vbTab & vbTab & tmpScaleGrossWeight)
sb.Append(vbCrLf)
Dim mMailMessage As New MailMessage()
Dim client As New SmtpClient(strEmailServer)

mMailMessage.From = New MailAddress("WR***@wrdcs.com")
mMailMessage.To.Add(New MailAddress(strEmailRecipient))

mMailMessage.Subject = "Discrepancy"
mMailMessage.Body = sb.ToString
mMailMessage.IsBodyHtml = False
mMailMessage.Priority = MailPriority.Normal

client.Send(mMailMessage)

mMailMessage.Dispose()

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.

Mar 8 '07 #3
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!
Mar 9 '07 #4
Osvaldo,

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

http://www.codeproject.com/useritems...SMTP_EMail.asp

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" <Os************@discussions.microsoft.comwrote in
message news:C1**********************************@microsof t.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.

Mar 18 '07 #5
Try adding credentials

client.Credentials = New Net.NetworkCredential(Me.MailServerUserName,
Me.MailServerPassword)

and you might want to try removing the call to dispose

Mar 20 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dale zhang | last post by:
Hi, I write an asp.net web application. It has a “Contact Us” page, where users fill in their email, subject and text and hit send. Then the email will go to my hard coded yahoo email...
34
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow...
4
by: Jerry Spence1 | last post by:
I am trying, without much luck, to find help in implementing an SMTP server/relay program from VB2005. My company produces software to go on customer's PCs. I am trying to implement email fault...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.