When using this bit of code, it sends two emails most of the time.
Sometimes it doesn't send two, but most of the time it does. I put the
system time (Now) in the Subject and each email has a different time by a
minute or so. I also tried to count the number of emails it is sending by
using the intEmail = intEmail + 1, but the number is always 1.Could anyone
tell me why this is happening or give me advice on how to change it. Thanks
in advance. Help is always greatly appreciated.
If Session("email" ) <> "" Then
intEmail = intEmail + 1
Dim strBody, strSubject as String
Dim email as New System.Web.Mail .MailMessage
strSubject = "Class Registration Confirmation" & " - " & Now & " - Email
#" & intEmail
strBody = Session("fname" ) & " " & Session("lname" ) & ", " & vbcrlf & _
"You registered for the following class." & vbcrlf & _
"Class Name: " & strClass & vbcrlf _
"Class Date: " & dtClass.DayOfWe ek.ToString & ", " &
dtClass.ToShort DateString & vbcrlf & _
"Class Length: " & strLength
email.To = Session("email" )
email.From = ConfigurationSe ttings.AppSetti ngs("AdminEmail ")
email.BodyForma t = Web.Mail.MailFo rmat.Text
System.Web.Mail .SmtpMail.SmtpS erver =
ConfigurationSe ttings.AppSetti ngs("MailServer ")
System.Web.Mail .SmtpMail.Send( email)
End If
--
Chuck Foster
Programmer Analyst
Eclipsys Corporation - St. Vincent Health System 3 3493
I think we have to look deeper, like to where this method is being called
from. If this is called from something fired through the Page_load event, and
you have to click a button to leave the page, then the Page_Load will acually
be 'hit' twice, since the button click will fire Page_Load before the click
event. In the above scenario, the intEmail variable will be reinitialized
unless persisted somehow (like in session) Try looking along those lines.
Hope this helps.
"chuckdfost er" wrote: When using this bit of code, it sends two emails most of the time. Sometimes it doesn't send two, but most of the time it does. I put the system time (Now) in the Subject and each email has a different time by a minute or so. I also tried to count the number of emails it is sending by using the intEmail = intEmail + 1, but the number is always 1.Could anyone tell me why this is happening or give me advice on how to change it. Thanks in advance. Help is always greatly appreciated.
If Session("email" ) <> "" Then intEmail = intEmail + 1 Dim strBody, strSubject as String Dim email as New System.Web.Mail .MailMessage strSubject = "Class Registration Confirmation" & " - " & Now & " - Email #" & intEmail strBody = Session("fname" ) & " " & Session("lname" ) & ", " & vbcrlf & _ "You registered for the following class." & vbcrlf & _ "Class Name: " & strClass & vbcrlf _ "Class Date: " & dtClass.DayOfWe ek.ToString & ", " & dtClass.ToShort DateString & vbcrlf & _ "Class Length: " & strLength email.To = Session("email" ) email.From = ConfigurationSe ttings.AppSetti ngs("AdminEmail ") email.BodyForma t = Web.Mail.MailFo rmat.Text System.Web.Mail .SmtpMail.SmtpS erver = ConfigurationSe ttings.AppSetti ngs("MailServer ") System.Web.Mail .SmtpMail.Send( email)
End If
-- Chuck Foster Programmer Analyst Eclipsys Corporation - St. Vincent Health System
I think we've found the problem. I am calling it in the page_load. I'll
move it to the previous page when they click the submit button. Thank you
so much. If you don't mind another question, can you explain how it is done
twice?
Chuck Foster
"Chip Pettit" <Ch********@dis cussions.micros oft.com> wrote in message
news:3B******** *************** ***********@mic rosoft.com... I think we have to look deeper, like to where this method is being called from. If this is called from something fired through the Page_load event,
and you have to click a button to leave the page, then the Page_Load will
acually be 'hit' twice, since the button click will fire Page_Load before the
click event. In the above scenario, the intEmail variable will be reinitialized unless persisted somehow (like in session) Try looking along those lines.
Hope this helps.
"chuckdfost er" wrote:
When using this bit of code, it sends two emails most of the time. Sometimes it doesn't send two, but most of the time it does. I put
the system time (Now) in the Subject and each email has a different time by
a minute or so. I also tried to count the number of emails it is sending
by using the intEmail = intEmail + 1, but the number is always 1.Could
anyone tell me why this is happening or give me advice on how to change it.
Thanks in advance. Help is always greatly appreciated.
If Session("email" ) <> "" Then intEmail = intEmail + 1 Dim strBody, strSubject as String Dim email as New System.Web.Mail .MailMessage strSubject = "Class Registration Confirmation" & " - " & Now & " -
Email #" & intEmail strBody = Session("fname" ) & " " & Session("lname" ) & ", " & vbcrlf
& _ "You registered for the following class." & vbcrlf &
_ "Class Name: " & strClass & vbcrlf _ "Class Date: " & dtClass.DayOfWe ek.ToString & ",
" & dtClass.ToShort DateString & vbcrlf & _ "Class Length: " & strLength email.To = Session("email" ) email.From = ConfigurationSe ttings.AppSetti ngs("AdminEmail ") email.BodyForma t = Web.Mail.MailFo rmat.Text System.Web.Mail .SmtpMail.SmtpS erver = ConfigurationSe ttings.AppSetti ngs("MailServer ") System.Web.Mail .SmtpMail.Send( email)
End If
-- Chuck Foster Programmer Analyst Eclipsys Corporation - St. Vincent Health System
This explanation is valid only if there is a button, or some other postback
event fired to leave the page... The page will always do the page_load, even
when the post is a postback. Other events are handled after the page_load
event. So, say you click to leave the page... page_load does it's thing, then
the click event handler does it's thing. Any thing in page_load gets done
again on postback.
Some things you could do to work with this behavior are:
1. Wrap the things you want to happen only once when the page loads for the
first time in an if (!IsPostBack) statement.
2. Save a counter to Session on the last load event (I use Page_PreRender)
and then load that varialble first thing in Page_Load on postback
And I'm sure there are more... Hope this helps.
Chip Pettit
"chuckdfost er" wrote: I think we've found the problem. I am calling it in the page_load. I'll move it to the previous page when they click the submit button. Thank you so much. If you don't mind another question, can you explain how it is done twice?
Chuck Foster
"Chip Pettit" <Ch********@dis cussions.micros oft.com> wrote in message news:3B******** *************** ***********@mic rosoft.com... I think we have to look deeper, like to where this method is being called from. If this is called from something fired through the Page_load event, and you have to click a button to leave the page, then the Page_Load will acually be 'hit' twice, since the button click will fire Page_Load before the click event. In the above scenario, the intEmail variable will be reinitialized unless persisted somehow (like in session) Try looking along those lines.
Hope this helps.
"chuckdfost er" wrote:
When using this bit of code, it sends two emails most of the time. Sometimes it doesn't send two, but most of the time it does. I put the system time (Now) in the Subject and each email has a different time by a minute or so. I also tried to count the number of emails it is sending by using the intEmail = intEmail + 1, but the number is always 1.Could anyone tell me why this is happening or give me advice on how to change it. Thanks in advance. Help is always greatly appreciated.
If Session("email" ) <> "" Then intEmail = intEmail + 1 Dim strBody, strSubject as String Dim email as New System.Web.Mail .MailMessage strSubject = "Class Registration Confirmation" & " - " & Now & " - Email #" & intEmail strBody = Session("fname" ) & " " & Session("lname" ) & ", " & vbcrlf & _ "You registered for the following class." & vbcrlf & _ "Class Name: " & strClass & vbcrlf _ "Class Date: " & dtClass.DayOfWe ek.ToString & ", " & dtClass.ToShort DateString & vbcrlf & _ "Class Length: " & strLength email.To = Session("email" ) email.From = ConfigurationSe ttings.AppSetti ngs("AdminEmail ") email.BodyForma t = Web.Mail.MailFo rmat.Text System.Web.Mail .SmtpMail.SmtpS erver = ConfigurationSe ttings.AppSetti ngs("MailServer ") System.Web.Mail .SmtpMail.Send( email)
End If
-- Chuck Foster Programmer Analyst Eclipsys Corporation - St. Vincent Health System This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: VB Programmer |
last post by:
My company has it's own webserver, which is going to host our ASP.NET web
application. We want the website to be able to send out emails.
1. What do I need on the server so that it has the abillity to send out
emails? It is a Windows 2000 Professional SP3 server.
2. Any examples (code, etc...) on how to send out emails via an ASP.NET
webform?
Thanks!
|
by: mark |
last post by:
I need to send order confirmation emails through my asp.net
storefront. With my Asp 3.0 sites I use cdonts with no issues. I've
researched the system.web.mail asp.net way and haven't got it to work.
It boils down to the online smtp server declaration. I say a
solution to active relay on the mail server but in the next sentence
it said doing this may open your server up to spam relays. Not what I
want to do. I've tried using cdonts...
|
by: Mr. x |
last post by:
Hello,
I am sending emails with Hebrew contents.
When receiving emails - I cannot see the Hebrew characters (it is not
outlook express configuration, because when receiving emails from friends -
I see hebrew, it is just sending by myself using *.aspx scripts).
In web.config I have the following :
<configuration>
<system.web>
|
by: Steve Thurston |
last post by:
Hi,
I'm attempting to send emails for the first time using ASP.NET, so I'm
hoping there's just a beginner's error going on here for me. But my
emails aren't reaching their destination, and I don't know why.
My "development" machine is just my home machine. I'm connected to
the Internet via an AOL dialup connection.
I am running on XP Pro and my IIS server is (apparently) configured
|
by: Nick Brown |
last post by:
Has any1 else had this error message. If so how do u solve it?
The specified module could not be found.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: The specified module could not be found.
Source Error:
| |
by: Brian M |
last post by:
I have an ASP.NET application using .NET Framework 1.1 running on a Windows
2003 server. The application uses SMTP to send emails. This application was
moved from an IIS 5 machine where it worked fine. However, now on the IIS 6
server the email notification does not work. The application is using
System.Web.Mail.MailMessage. The error and trace is:
System.IO.FileNotFoundException: The specified module could not be found. at...
|
by: farhan wajahat |
last post by:
i have made a command button and on the click event of
the button following code is mentioned:
im mailnew As New MailMessage()
mailnew.From = "financialadjustment@mobilink.net"
mailnew.To = "farhan.w@mobilink.net"
mailnew.Cc = "financialadjustment@mobilink.net"
mailNew.Subject = "New Record Entered
Successfully"
mailNew.Body = "Data successfully entered by user
|
by: tshad |
last post by:
I am trying to figure out the best way to send automated emails?
I have emails that I want to send out to certain clients that need them
either daily or weekly.
How would I do in asp.net?
Or is it better to write normal app to handle this that I run from the
schedular?
|
by: Joey |
last post by:
I am currently developing a C# asp.net application where users are
required to register. The application then generates a simple, plain
text email and sends it to the new user.
I have been trying to use the MailMessage and SmtpMail classes from the
System.Web.Mail namespace (built in to .net) to do this. It is my
understanding that these classes use CDONTS (cdosys.dll) and the SMTP
mail service on the server to send the messages....
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |