|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sending email from Windows application Not working.I have a shared function for sending Email using SMTP. It works fine in a ASP.NET web application. But when I use it in a VB.Net Windows application, it always gave me an error: "Could not access 'CDO.Message' object." I am runing both Web and Windows App on same test PC, and SMTP server is hosted on another machine. The function for sending Email is: Public Shared Function SendEmail(ByVal email_From As String, _ ByVal email_To As String, _ ByVal email_Subject As String, _ ByVal email_Body As String, _ Optional ByVal email_CC As String = "", _ Optional ByVal email_BCC As String = "", _ Optional ByRef email_AttachmentList As System.Collections.IList = Nothing) Dim email As New System.Web.Mail.MailMessage email.From = email_From email.To = email_To email.Subject = email_Subject email.Body = email_Body email.Cc = email_CC email.Bcc = email_BCC email.BodyFormat = Web.Mail.MailFormat.Text If Not email_AttachmentList Is Nothing Then email.Attachments.Add(email_AttachmentList) End If Try System.Web.Mail.SmtpMail.SmtpServer = "SMTP_XXX" System.Web.Mail.SmtpMail.Send(email) Catch ex As Exception Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish(ex) End Try End Function --------------- Does anybody have any idea? Thanks When I use the following function to test the SMTP server, it return
true in web app but return false in Win app. My Test PC is XP pro. Public Shared Function DetectSMTPServer( _ Optional ByVal host As String = "XXX") _ As Boolean Dim tcp As New System.Net.Sockets.TcpClient Dim ServerExists As Boolean = False Try tcp.Connect(host, 25) ServerExists = True Catch ex As Exception ServerExists = False Finally tcp.Close() End Try Return ServerExists End Function
FOR ALL - Best Practices for navigating within code? -plus - Add-In's that help?
Concurrency violation at update A Service in VB.NET 2005 using a form ? How to dynamically instantiate a base calss (w/ args to constructor?) Where can we buy VB.net? How Microsoft does it? do event Date/Time problem VB6 to VB.Net ActiveX Document DLL (VBD) Inquiry... crystal report question |
|||||||||||||||||||||||