send mail in .NET 2.0

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

sendmail in .NET 2.0 is as useless as it was in .NET 1.x
I can't find out how to make it work. Not to mention how to write a setup
project that tests/installs its requirements correctly.

the difference to previous version is that .NET 1.x gave no error message at
all and .NET 2.0 gives useless error message when sendmail fails.

why is Microsoft not able to ship a sendmail class that works out of the box
at least with their own hotmail.com infrastructure?
and which does not need access to windows services configuration which
students don't have?

Or buy one of the companies that offer send mail + receive mail and ship
this as part of .Net 2.0 bugfix release.

over and out. herbert
 
..NET 2.0 mail is much better than .NET 1.1 -- it is structured differently
so if you port to 2.0 you'll need to change a few things, but it works well
with secure severs now at least, don't know if it still has the >1024
character problem (aka you need to insert crlf in body text to prevent the
bizarre symbols that may appear).

I believe you have to go a couple of levels deep to get the exact error, but
the error is there. Keep in mind it can only return what the EMail server
reports to it.
 
Rob,

Can you make any of the samples (from VS online help, MSDN or related web
sites) work without deep knowledge of the computer your code executes???

In other words: mabye the smtpclient class in .NET 2.0 is better structured,
however its description is useless for novice to medium programmers (ie those
without sysadmin experience and access rights).

And even if you succeed, there is still no way to create a setup project
with reasonable effort that can do what you do.

Let's ask Microsoft to prove it: please give us a complete VS.2005 project
to download that sends eMail and includes an installer project.

herbert
 
Hope you can get thru my VB.NET code -- this is implemented from one of my
web applications.

Imports System.Net.Mail

' Customer and Site are my classes
' MyCompany -- well that is obvious ;)

' Validate Customer EMail address, Site EMail Server, Site EMail
Confirmation address have been provided
If Not String.IsNullOrEmpty(Customer.EMail) And _
Not String.IsNullOrEmpty(Site.EMailServer) And _
Not String.IsNullOrEmpty(Site.EMailServerConfirmationAddy) Then

Dim Phone As New MyCompany.Utilities.Conversion
Dim OS As New MyCompany.Utilities.OperatingSystem

Dim smtpMailClient As New System.Net.Mail.SmtpClient
Dim SiteConfirmEMail = New
System.Net.Mail.MailAddress(Site.EMailServerConfirmationAddy, Site.SiteName)
Dim CustomerEMail = New
System.Net.Mail.MailAddress(Customer.EMail, Customer.FirstName & " " &
Customer.LastName)
Dim SiteEMail = New
System.Net.Mail.MailAddress(Site.FacilityEMail, Site.SiteName)
Dim BccEMail = New System.Net.Mail.MailAddress(OS.Get_EMailBcc,
"")

Dim ConfirmationMessage As New System.Net.Mail.MailMessage
With ConfirmationMessage

.From = SiteConfirmEMail
.To.Add(CustomerEMail)
.Bcc.Add(BccEMail)
.CC.Add(SiteEMail)

.Subject = Site.SiteName & " Confirmation"
.IsBodyHtml = True
.Priority = System.Net.Mail.MailPriority.Normal
.Body = Build_Letter_HTML(Customer, Site)

End With

Try

With smtpMailClient

.Host = Site.EMailServer
.DeliveryMethod = SmtpDeliveryMethod.Network

If Site.EMailServerAuthentication Then
.Credentials = New
System.Net.NetworkCredential(Site.EMailServerAuthUserID,
Site.EMailServerAuthPassword)
End If

.Send(ConfirmationMessage)

End With

Catch exSMTP As SmtpException

lb_WelcomeCustomer.Text =
Build_MailServerDown_HTML(Customer, Site)

Catch ex As Exception

lb_WelcomeCustomer.Text =
Build_ConfirmationDown_HTML(Customer, Site)

End Try

Else

lb_WelcomeCustomer.Text = "Invalid E-mail account or E-Mail
server not configured correctly."

End If
 
Unless you have configured IIS to use SMTP properly, nothing will make the
System.Net.Mail stuff work properly.
 
Back
Top