SMTP Mail

  • Thread starter Thread starter Test0Man
  • Start date Start date
T

Test0Man

Hey,

I've built a small email application(I use the System.Web.Mail
namespace), when I send the email/emails with attachments they work
very well, my network technician says its works pretty well, expect
that there is no disconnect, my program simple just shuts down. I was
wondering if there isnt any way to tell the server that we are quiting
and done sending. It seems I dont send any quit command so that the
smtp server releases my connection.

Base of the code:

SmtpMail.SmtpServer = "myMailserver.com";

MailMessage mail = new MailMessage();
mail.To = this.smtpTo.Text;
mail.Cc = this.stmpCC.Text;
mail.Bcc = this.stmpBCC.Text;
mail.From = this.smtpFrom.Text;
mail.Subject = this.stmpSubject.Text;
mail.Body = this.MessageBox.Text;
MailAttachment attachment = new MailAttachment(AttachmentBox.Text);
mail.Attachments.Add(attachment);
SmtpMail.Send(mail);

Best Regards
 
I think that the System.Web.Mail namespace will close the connection to
the SMTP server automatically after sending.

Even if it doesn't, I think that Mail uses sockets. If the socket is
terminated on the side of your applicatoin, your SMTP server will close
the socket on it's end.
 
Don't knwo if this helps but a dot "." on a line by itself terminates the
message (at least in sendmail). It may tell the server to disconnect as
well.

jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top