|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
System.Web.Mail.Smtp namespaceIs there anybody out there that has successfully done this? I am having major problems and need a step by step guide into the world of system.web and IIS. The reading I have done(alot) has been pretty useless in helping me understand the various bits required. The error I get is: On a pc running win2k with IIS and Lotus Notes System.Runtime.InteropServices.SEHException: External component has thrown an Exception at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) at System.Activator.CreateInstance(Type type, Boolean nonPublic) at System.Web.Mail.CdoSysHelper.Send(MailMessage message) at System.Web.Mail/SmtpMail.Send(MailMessage message) at MyAppName.MyFormName.MyMailingFunction The error I get is: On a DEV(not networked) pc running winXP with with IIS but without Lotus Notes System.Web.HttpException: Could not access 'CDO.Message' object ----> System.Reflection.TargetInvocationexception: Exception has been thrown by the target of an invocation ---> System.Runtime.InteropServices.COMException(0x80040213): The transport failed to connect to the server CODE::: Imports System.Web.Mail Private Sub Mail1() Dim myMessage As New MailMessage Dim myMailServer As SmtpMail myMessage.BodyFormat = MailFormat.Text 'or MailFormat.Html myMessage.Priority = MailPriority.Normal ', High, or Low myMessage.From = "marc.mcguck***@quinn-direct.com" 'From Address myMessage.To = "marc.mcguck***@quinn-direct.com" 'To Address 'myMessage.Cc = "someonee***@somedomain.com" 'Send a Carbon-Copy 'myMessage.Bcc = "some***@diffdomain.com" 'Send a Blind Carbon-Copy myMessage.Subject = "VB.NET E-mail Test" 'Below is the Body of the E-mail I did it this way to show that this property 'can be treated as a string. myMessage.Body = "This is a test of a Windows E-mailer<BR>" & vbCrLf myMessage.Body &= "<font color=blue>TEST</font><br>" & vbCrLf & _ "<font color=red>TEST</font><br>" & vbCrLf 'Add an attachment to your Email. Attachments in Windows applications are touchy. 'In the project it will throw an error if you don’t have the file in the 'Solution Explorer. But just running the .exe it seems to be fine with any file. 'Make sure file has full pathing otherwise you will definitely get an error. 'myMessage.Attachments.Add(New System.Web.Mail.MailAttachment(File)) '10.2.0.4 'cavan02.quinn-direct.com) 'myMailServer.SmtpServer = "cavan02.quinn-direct.com" 'This is your mail server myMailServer.SmtpServer = "cn2k-03321.quinn-direct.com" 'This is your mail server Try myMailServer.Send(myMessage) Catch ex As Exception MessageBox.Show(ex.ToString) MessageBox.Show(ex.InnerException.ToString) MessageBox.Show(ex.Source) End Try myMessage = Nothing End Sub Have you looked at http://systemwebmail.com/ ?
They have a section for troubleshooting... -- Show quoteHide quoteBest regards, Carlos J. Quintero MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA You can code, design and document much faster. Free resources for add-in developers: http://www.mztools.com "marcmc" <mar***@discussions.microsoft.com> escribió en el mensaje news:C9BAB947-472C-4402-BBF3-E58F41842315@microsoft.com... > Trying to send an eMail frommy vb.net App. > Is there anybody out there that has successfully done this? > I am having major problems and need a step by step guide into the world of > system.web and IIS. The reading I have done(alot) has been pretty useless > in > helping me understand the various bits required. > > The error I get is: On a pc running win2k with IIS and Lotus Notes > System.Runtime.InteropServices.SEHException: External component has thrown > an Exception > at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) > at System.Activator.CreateInstance(Type type, Boolean nonPublic) > at System.Web.Mail.CdoSysHelper.Send(MailMessage message) > at System.Web.Mail/SmtpMail.Send(MailMessage message) > at MyAppName.MyFormName.MyMailingFunction > > The error I get is: On a DEV(not networked) pc running winXP with with IIS > but without Lotus Notes > > System.Web.HttpException: Could not access 'CDO.Message' object ----> > System.Reflection.TargetInvocationexception: Exception has been thrown by > the target of an invocation ---> > System.Runtime.InteropServices.COMException(0x80040213): The transport > failed to connect to the server > > > > CODE::: > Imports System.Web.Mail > > Private Sub Mail1() > Dim myMessage As New MailMessage > Dim myMailServer As SmtpMail > > myMessage.BodyFormat = MailFormat.Text 'or MailFormat.Html > myMessage.Priority = MailPriority.Normal ', High, or Low > myMessage.From = "marc.mcguck***@quinn-direct.com" 'From Address > myMessage.To = "marc.mcguck***@quinn-direct.com" 'To Address > 'myMessage.Cc = "someonee***@somedomain.com" 'Send a Carbon-Copy > 'myMessage.Bcc = "some***@diffdomain.com" 'Send a Blind Carbon-Copy > myMessage.Subject = "VB.NET E-mail Test" > 'Below is the Body of the E-mail I did it this way to show that > this > property > 'can be treated as a string. > myMessage.Body = "This is a test of a Windows E-mailer<BR>" & > vbCrLf > myMessage.Body &= "<font color=blue>TEST</font><br>" & vbCrLf & _ > "<font color=red>TEST</font><br>" & vbCrLf > > 'Add an attachment to your Email. Attachments in Windows > applications are touchy. > 'In the project it will throw an error if you don't have the file > in > the > 'Solution Explorer. But just running the .exe it seems to be fine > with any file. > 'Make sure file has full pathing otherwise you will definitely get > an error. > 'myMessage.Attachments.Add(New > System.Web.Mail.MailAttachment(File)) > > '10.2.0.4 > 'cavan02.quinn-direct.com) > > 'myMailServer.SmtpServer = "cavan02.quinn-direct.com" 'This is your > mail server > myMailServer.SmtpServer = "cn2k-03321.quinn-direct.com" 'This is > your mail server > Try > myMailServer.Send(myMessage) > Catch ex As Exception > MessageBox.Show(ex.ToString) > MessageBox.Show(ex.InnerException.ToString) > MessageBox.Show(ex.Source) > End Try > > myMessage = Nothing > End Sub Thankyou Carlos. You are the first to reply to any of my posts today!
I will look at that resource. Sending an eMail is actually a second option for me. What I really would love to do is send a text message(SMS) instead. Have you any references or personal experience with this? marc I got it working but am using MS Exchange / Outlook for mail not
Domino/Notes .... Dim Message As System.Web.Mail.MailMessage = New System.Web.Mail.MailMessage Message.To = txtTo.Text Message.From = txtFrom.Text Message.Subject = txtSubject.Text Message.Body = txtBody.Text Try SmtpMail.SmtpServer = txtServer.Text ' Works whether this is set or not (?) SmtpMail.Send(Message) Catch ex As Exception MessageBox.Show(ex.Message) End Try NOTES: Send(), and SmtpServer are both Shared members of the SmtpMail class, there is no need to instantiate myMailServer to use them As mentioned above, it appears that SmtpServer does not NEED to be set (at least on WinXP, or Win 2000 Server systems). It works fine for me wether or not I set it. Hi Alan
Is the code all you needed to do or did you have work to do with IIS, or the exchange server. I'm not so worried about the code, I'll figure that out eventually but any other factors that need configuration. I'm trying to build a picture of how this works on a broad level. VCheers marc Show quoteHide quote "alanto***@users.com" wrote: > I got it working but am using MS Exchange / Outlook for mail not > Domino/Notes > > > .... > > Dim Message As System.Web.Mail.MailMessage = New > System.Web.Mail.MailMessage > Message.To = txtTo.Text > Message.From = txtFrom.Text > Message.Subject = txtSubject.Text > Message.Body = txtBody.Text > > Try > > SmtpMail.SmtpServer = txtServer.Text ' Works whether > this is set or not (?) > > SmtpMail.Send(Message) > > Catch ex As Exception > > MessageBox.Show(ex.Message) > > End Try > > > NOTES: > > Send(), and > SmtpServer > > are both Shared members of the SmtpMail class, there is no need to > instantiate myMailServer to use them > > As mentioned above, it appears that SmtpServer does not NEED to be set > (at least on WinXP, or Win 2000 Server systems). It works fine for me > wether or not I set it. > > When I use Alan's code I get
System.Web.HttpException: Could not access 'CDO.Message' object I have searched my XP machine and cdonts.dll and cdosys.dll don't seem to exist You can use a networkstream, a streamreader and a tcpClient to open a
connection to your smtp server and communicate with it directly. I don't need to send attachments though so I don't have any experience with that. ********************************** '* '* Shawn Shelton '* This code will send email using smtp '* It is currently being used to send mail to me '* when some portion of code errors. '***************************************** Option Explicit On Option Strict On Imports System.IO Imports System.Net Imports System.Net.Sockets Module SendError Dim NetStrm As NetworkStream Public Sub GenErrMail(ByVal User As String, ByVal RemoteMachine As String, ByVal Message As String) Dim localName As String = System.Environment.UserName Dim UserMail As String = User & "@somewhere.edu" Dim TheDate As String = GetTime() Try Dim reader As StreamReader Dim buffer As String Dim SmtpClient As New TcpClient SmtpClient.Connect("smtpserver.somewhere.edu", 25) NetStrm = SmtpClient.GetStream() reader = New StreamReader(SmtpClient.GetStream()) buffer = reader.ReadLine() SendCommand("HELO " & UserMail) buffer = reader.ReadLine() SendCommand("MAIL FROM:" & UserMail) buffer = reader.ReadLine SendCommand("RCPT TO: some***@somewhere.edu") buffer = reader.ReadLine SendCommand("DATA") buffer = reader.ReadLine SendCommand("Subject: Lab ERROR") SendCommand("FROM:" & UserMail) SendCommand("DATE:" & TheDate) SendCommand("TO: some***@somewhere.edu") SendCommand( Message) SendCommand(vbCrLf) SendCommand(vbCrLf) SendCommand(vbCrLf & ".") buffer = reader.ReadLine SendCommand("QUIT") buffer = reader.ReadLine NetStrm.Close() reader.Close() SmtpClient.Close() buffer = Nothing Catch ex As Exception 'MsgBox(ex.Message & vbCrLf & ex.Source) End Try End Sub Private Sub SendCommand(ByVal text As String) Dim szData() As Byte text = text & vbCrLf szData = System.Text.Encoding.ASCII.GetBytes(text.ToCharArray) NetStrm.Write(szData, 0, szData.Length) End Sub Private Function GetTime() As String Dim Buffer As String Buffer = OpenConnection("timeserver.somewhere.edu", 13) GetTime = FormatDateTime(Buffer) End Function Private Function OpenConnection(ByVal server As String, ByVal Port As Integer) As String Dim Buffer As String Dim tcpClient As New System.Net.Sockets.TcpClient Dim reader As StreamReader Try tcpClient.Connect(server, Port) reader = New StreamReader(tcpClient.GetStream()) Buffer = reader.ReadLine() reader.Close() OpenConnection = Buffer tcpClient.Close() Catch ex As Exception OpenConnection = Buffer End Try End Function Public Function FormatDateTime(ByVal NetTime As String) As String Dim strDate As String Dim strTime As String strDate = Trim(Mid(NetTime, 1, 3)) & ", " & Trim(Mid(NetTime, 8, 3)) & " " & Trim(Mid(NetTime, 4, 4)) & " " & Trim(Mid(NetTime, 24, 5)) strTime = Trim(Mid(NetTime, 12, 9)) & " " & "-0700 (MST)" FormatDateTime = strDate & " " & strTime End Function End Module "Shawn" <TechniSh***@gmail.com> wrote in news:1120169320.871829.89400 @g43g2000cwa.googlegroups.com:> You can use a networkstream, a streamreader and a tcpClient to open a This is a very bad idea. SMTP base protocol is very simple, but with authenticatino, EHELO, and other > connection to your smtp server and communicate with it directly. I > don't need to send attachments though so I don't have any experience > with that. extensions user code is quickly broken. You can try something like Indy, which is free and implements all of this: http://www.indyproject.org/ -- Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/ "Programming is an art form that fights back" Make your ASP.NET applications run faster http://www.atozed.com/IntraWeb/ CDO requires it to be installed, and can have other issues as well. Try a native SMTP example:
http://www.codeproject.com/csharp/IndySMTP.asp -- Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/ "Programming is an art form that fights back" Develop ASP.NET applications easier and in less time: http://www.atozed.com/IntraWeb/
INI or XML
Adding desktop shortcuts and start program entries WebBrowser control error Get names of opened windows and their process name manged alternative to get the complete text from each open window ApplicationDomains Calculating Time in VB .Net How to use OCX? is there way to send email throught outlook express without mapi controls ? reference dependency warnings during build |
|||||||||||||||||||||||