Hello all:
Using an "Imports System.Web.Mail" clause at the head of my module, and
after executing the following code:
Dim msg As New MailMessage
msg.From = sender
msg.To = recipient
msg.Attachments.Add(New MailAttachment(attachFile))
msg.Subject = subjectString
SmtpMail.SmtpServer = mailservername
SmtpMail.Send(msg)
The message is sent just fine, but then my application refuses to
terminate... when sub Main ends, it just hangs, and a glance at my task
manager shows it to be using ever-increasing amounts of memory, and my
CPU usage shoots up to 100%, and I actually have to kill the
application for it to terminate. This did not start happening until
AFTER I installed the code above...
I see the same behavior whether I explicitly destroy the MailMessage
object or not, whether I reset the mail server name or not...
Any help will be greatly appreciated!
Cheers,
zdrakec 19 3264
I don´t know the asnwer, but most of them related to System.Web.Mail are at: http://systemwebmail.com/
--
Carlos J. Quintero
MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster. http://www.mztools.com
<zd*****@yahoo.com> escribió en el mensaje
news:11**********************@c13g2000cwb.googlegr oups.com... Hello all:
Using an "Imports System.Web.Mail" clause at the head of my module, and after executing the following code:
Dim msg As New MailMessage msg.From = sender msg.To = recipient msg.Attachments.Add(New MailAttachment(attachFile)) msg.Subject = subjectString SmtpMail.SmtpServer = mailservername SmtpMail.Send(msg)
The message is sent just fine, but then my application refuses to terminate... when sub Main ends, it just hangs, and a glance at my task manager shows it to be using ever-increasing amounts of memory, and my CPU usage shoots up to 100%, and I actually have to kill the application for it to terminate. This did not start happening until AFTER I installed the code above...
I see the same behavior whether I explicitly destroy the MailMessage object or not, whether I reset the mail server name or not... Any help will be greatly appreciated!
Cheers, zdrakec
Thanks for the link, but unfortunately, I did not see anything that
addresses this issue there...
zdrakec
Carlos J. Quintero [.NET MVP] wrote: I don´t know the asnwer, but most of them related to System.Web.Mail
are at: http://systemwebmail.com/
Zdrakec,
This snippet you show now in this newsgroup has been here often.
Mostly is the error that the smtp mailserver is not correct. That is not in
your situation. Therefore in my opinion has it to do with an endless loop
somewhere however not in this snippet.
Just my thought,
Cor
Hello Cor:
Well, this was my first thought, but there IS no loop between the
execution of this code and the exit from Sub Main.In fact, if I step
through execution after the send method call, everything runs just
fine... but after exiting sub Main, the application doesn't terminate.
This ONLY happens if the SmptMail.Send(msg) is invoked, otherwise
not...
Still puzzled...
Thanks,
zdrakec
Zdrakec,
Have you to test it (not for original) tried a me.close direct after the
send?
Cor
<zd*****@yahoo.com> schrieb; Using an "Imports System.Web.Mail" clause at the head of my module, and after executing the following code:
Dim msg As New MailMessage msg.From = sender msg.To = recipient msg.Attachments.Add(New MailAttachment(attachFile)) msg.Subject = subjectString SmtpMail.SmtpServer = mailservername SmtpMail.Send(msg)
The message is sent just fine, but then my application refuses to terminate... when sub Main ends, it just hangs, and a glance at my task manager shows it to be using ever-increasing amounts of memory, and my CPU usage shoots up to 100%, and I actually have to kill the application for it to terminate. This did not start happening until AFTER I installed the code above...
If you are running virusscanners or firewalls, turn them off temporarily to
be sure that they don't cause the problem.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Hello Cor, Herfried:
There is no me.close to execute, this is being run from a module, not a
form class object. I turned off my virus scanner and firewall, but with
no change. I point out that the mail message is successfully being
sent!
I tried doing a "threading.thread.currentthread.abort" command, and
trapping the resulting ThreadAbortException; however, while this does
in fact kill the app, it also gives me that annoying message
"Application has caused a problem... do you want to create a dump file"
dialog. Since this will end up being an unattended server process, I
can't have a dialog box open! I get this error despite the fact that
the exception is being caught...
More suggestions?
Cheers,
zdrakec
A co-worker had a similar problem. He commented out the line
SmtpMail.SmtpServer = mailservername
and SmtpMail worked.
This assumes the PC can send SmtpMail.
He thinks there was some bug in his mailservername value.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uU**************@tk2msftngp13.phx.gbl... <zd*****@yahoo.com> schrieb; Using an "Imports System.Web.Mail" clause at the head of my module, and after executing the following code:
Dim msg As New MailMessage msg.From = sender msg.To = recipient msg.Attachments.Add(New MailAttachment(attachFile)) msg.Subject = subjectString SmtpMail.SmtpServer = mailservername SmtpMail.Send(msg)
The message is sent just fine, but then my application refuses to terminate... when sub Main ends, it just hangs, and a glance at my task manager shows it to be using ever-increasing amounts of memory, and my CPU usage shoots up to 100%, and I actually have to kill the application for it to terminate. This did not start happening until AFTER I installed the code above... If you are running virusscanners or firewalls, turn them off temporarily
to be sure that they don't cause the problem.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Hello Bill:
Well, yes, when I comment that out, the problem goes away. However, the
message also does not get sent! This is why I tried resetting this to
an empty string after the send call, thus:
msg.Attachments.Clear()
msg = Nothing
SmtpMail.SmtpServer = ""
Thanks though!
More?
Cheers,
zdrakec
Zdrakec,
Why dont you than not make a nice class from it so that you can instance it
and with that let it go automaticly out of scope and be cleaned up?
Cor
Well, that's a good idea, I'll try that... but I certainly expected it
to drop out of scope once the function that invoked it returned!
Cheers,
zdrakec
Tried it. No change.
<<sigh>>
More ideas?
Cheers,
zdrakec
It looks like mailservername is an invalid SmtpServer name. You can look at
the value to check.
The code below is using "" as the SmtpServer name. I would not expect this
to work.
If you set
SmtpMail.SmtpServer = Nothing
I would expect the same results as just commenting out the line. In that
case it depends on whether your PC can send Smtp e-mail - sounds like it is
not enabled on you PC.
<zd*****@yahoo.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com... Hello Bill:
Well, yes, when I comment that out, the problem goes away. However, the message also does not get sent! This is why I tried resetting this to an empty string after the send call, thus:
msg.Attachments.Clear() msg = Nothing SmtpMail.SmtpServer = ""
Thanks though!
More?
Cheers, zdrakec
Hi Bill:
I want to point out that when I set the server name, the message gets
sent... which implies that the server name is indeed valid. I happen to
know the server name is good, since is the one my regular account uses
:)
I have tried setting SmtpMail.SmtpServer = Nothing, with the same
results as before.
I agree that something about setting the name is causing the problem...
I'm just not sure what....
Thanks,
zdrakec
Zdrakec,
Not tonight anymore for me, however maybe when you sent some more code
tomorrow or will somebody else have a look to it.
Now it is in my opinion guessing in the dark,
Cor
The class code is quite simple:
Option Strict On
Option Explicit On
Imports System.Web.Mail
Friend Class SendMail
Private msg As MailMessage
Private attach As MailAttachment
Private serverName As String
Friend Sub New(ByVal recipient As String, ByVal sentby As String, _
ByVal server As String, ByVal subject As String, Optional ByVal
fileName As String = "")
msg = New MailMessage
msg.From = sentby
msg.To = recipient
msg.Subject = subject
If Len(Trim(fileName)) > 0 Then
attach = New MailAttachment(fileName)
msg.Attachments.Add(attach)
End If
serverName = server
End Sub
Friend Sub SendMessage()
If msg Is Nothing Then Exit Sub
SmtpMail.SmtpServer = serverName
SmtpMail.Send(msg)
End Sub
Friend Sub Destroy()
Me.Finalize()
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
attach = Nothing
If Not msg Is Nothing Then
msg.Attachments.Clear()
msg = Nothing
End If
SmtpMail.SmtpServer = Nothing
End Sub
End Class
When my application executes the SendMessage method above, and ONLY
when it also sets the name of the SmtpMail.SmtpServer property to the
correct exchange server, what happens is:
1. The message is sent.
2. The application continues to execute normally, including the
destruction of the class object.
3. When the application exits Main (which is the startup object),
instead of terminating (as it normally does), it hangs. If I examine
the app with Task Manager, I find that the CPU utilization associated
with this .exe has gone to 99 (!) and stays there, even though nothing
else gets locked up... just this app, which refuses to terminate. I end
up having to use Task Manager to kill it.
I have tried all sorts of things, but the bottom line is: I only get
this behavior if I set the SmtpMail.SmtpServer property to the name of
my exchange server.
More suggestions? I'm starting to run out of things to try!
Cheers,
zdrakec
Zdrakec,
This is in my opinion the first time you tell that it is the Exchange
server.
Here a message thread about that, maybe you find something because that is
something special, I saw it a very long while ago and I hope that it is in
this thread for you..
And delete all those crazy extra's you have done.
When they did not work, dont keep them than.
(I mean all that finalizing and setting to nothing, that should do the
framework) http://groups-beta.google.com/group/...ee8dbd2030f4c3
When trying by the way you can in your code (withouth that finalizing) use
any SMtp.sever. That can as well be the one which is from your provider.
Don't use that for production because they are probably not happy with it.
I hope this helps?
Cor
I moved the code to a different machine, and the problem went away...
<<sigh>> thanks for the input, this one was frustrating..
Cheers,
zdrakec
Cor Ligthert wrote: Zdrakec,
This is in my opinion the first time you tell that it is the Exchange
server.
Here a message thread about that, maybe you find something because
that is something special, I saw it a very long while ago and I hope that it
is in this thread for you..
And delete all those crazy extra's you have done. When they did not work, dont keep them than. (I mean all that finalizing and setting to nothing, that should do
the framework)
http://groups-beta.google.com/group/...ee8dbd2030f4c3 When trying by the way you can in your code (withouth that
finalizing) use any SMtp.sever. That can as well be the one which is from your
provider. Don't use that for production because they are probably not happy
with it. I hope this helps?
Cor
Before my co-worker had a similar problem, I was trying to use SmtpMail
also. I did not set the SmtpServer property.
There is a folder on my PC named
C:\Inetpub\mailroot\Badmail
and 2 or 3 files with different extensions were appearing there each tile I
tried to send mail. Used Notepad to look at the file contents. The file
with the .BAD extension looked like a fully formatted version of the mail I
was trying to send. One of the other files, had an error message explaining
in a very cryptic/useless manner what the problem was - but it also had an
error number which I was able to look up in the knowledgebase.
The knowledgebase article said, in my words, the message was improperly
formatted. The message had to have a From, a To, and either a Subject or a
Body - my message had all four.
My From value was "My Mailer". Since it did not work I was willing to try
anything - so I changed it to "My-Mailer" and it worked. From can't have
embedded spaces??
<zd*****@yahoo.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com... The class code is quite simple:
Option Strict On Option Explicit On
Imports System.Web.Mail
Friend Class SendMail Private msg As MailMessage Private attach As MailAttachment Private serverName As String
Friend Sub New(ByVal recipient As String, ByVal sentby As String, _ ByVal server As String, ByVal subject As String, Optional ByVal fileName As String = "") msg = New MailMessage msg.From = sentby msg.To = recipient msg.Subject = subject If Len(Trim(fileName)) > 0 Then attach = New MailAttachment(fileName) msg.Attachments.Add(attach) End If serverName = server End Sub
Friend Sub SendMessage() If msg Is Nothing Then Exit Sub SmtpMail.SmtpServer = serverName SmtpMail.Send(msg) End Sub
Friend Sub Destroy() Me.Finalize() End Sub
Protected Overrides Sub Finalize() MyBase.Finalize() attach = Nothing If Not msg Is Nothing Then msg.Attachments.Clear() msg = Nothing End If SmtpMail.SmtpServer = Nothing End Sub End Class
When my application executes the SendMessage method above, and ONLY when it also sets the name of the SmtpMail.SmtpServer property to the correct exchange server, what happens is: 1. The message is sent. 2. The application continues to execute normally, including the destruction of the class object. 3. When the application exits Main (which is the startup object), instead of terminating (as it normally does), it hangs. If I examine the app with Task Manager, I find that the CPU utilization associated with this .exe has gone to 99 (!) and stays there, even though nothing else gets locked up... just this app, which refuses to terminate. I end up having to use Task Manager to kill it.
I have tried all sorts of things, but the bottom line is: I only get this behavior if I set the SmtpMail.SmtpServer property to the name of my exchange server.
More suggestions? I'm starting to run out of things to try!
Cheers, zdrakec This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jason |
last post by:
Hi
not sure if this is the write place, but i really need some help with
this...!
I have a piece of code that sends email using the SmtpMail...
|
by: Jens Øster |
last post by:
Hi
I am writing a ASP.NET web application that must sent some e-mails.
I get the exception “Could not access 'CDO.Message' object†when I...
|
by: Jens |
last post by:
Hi
I am writing a ASP.NET web application that must sent some e-mails.
I get the exception “Could not access 'CDO.Message' object†when I...
|
by: Aren Cambre |
last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's
BodyFormat = MailFormat.Html? I've searched all over the place and
cannot find a...
|
by: Eric van Wijk |
last post by:
Hi All,
After installing SP1 for Windows 2003, I'm running into the 'Error
loading type library/DLL' exception when using CDO through...
|
by: ra294 |
last post by:
Hi,
I have a web application that sends Email on certain events.
The problem is that sometimes the local mail server does not response to...
|
by: H. Blijlevens |
last post by:
Hi y'all!
I'm trying to adapt a VB.Net application that a former employee built to
keep track of product issues that our customers report.
...
|
by: Nathan Truhan |
last post by:
Hello,
I have a WinForms application to send out emails to a large group of
students. This is not spam, but mail from our university to the...
|
by: OlafMeding |
last post by:
Below are 2 files that isolate the problem. Note, both programs hang
(stop responding) with hyper-threading turned on (a BIOS setting), but
work...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: jalbright99669 |
last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the...
|
by: Carina712 |
last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...
| |