Lanc1988 Posted February 23, 2004 Posted February 23, 2004 I am trying to use the following code to let users of my program send emails to an email address without having to use their email program. Dim subjectLine As String Dim emailToSend As New System.Web.Mail.MailMessage Dim messageBody As String 'CREATE MESSAGE BODY Try messageBody = TextBox3.Text 'CREATE MESSAGE HEADER subjectLine = "Submitted Information" emailToSend.From = "RSSK" emailToSend.To = "rs_sidekick@msn.com" emailToSend.Body = messageBody.ToString emailToSend.Subject = subjectLine System.Web.Mail.SmtpMail.SmtpServer = "smtp.charter.net" System.Web.Mail.SmtpMail.Send(emailToSend) Catch ex As Exception Throw ex End Try emailToSend = Nothing Can anyone see whats wrong? I am thinking I may be using the wrong smtp address, maybe its in the wrong format. Quote
Lanc1988 Posted February 24, 2004 Author Posted February 24, 2004 I get an error when I click the Button to submit, it highlights End Try and says: An unhandled exception of type 'System.Web.HttpException' occurred in Program.exe Additional information: Could not access 'CDO.Message' object. Quote
Administrators PlausiblyDamp Posted February 24, 2004 Administrators Posted February 24, 2004 You would get an unhandled exception in your catch block you are just re-throwing it. You should be handling the error there. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Lanc1988 Posted February 25, 2004 Author Posted February 25, 2004 so how would i edit this: Catch ex As Exception Throw ex End Try emailToSend = Nothing to get it to work? Quote
Administrators PlausiblyDamp Posted February 25, 2004 Administrators Posted February 25, 2004 Depends on what you want to do if an error occurs. I'm fairly sure that you don't want to be doing Throw ex though - you may as well not bother with the try ... catch if you are simply going to generate the same error. What do you want to do if an error occurs? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Lanc1988 Posted February 25, 2004 Author Posted February 25, 2004 but there shouldn't be an error...? What I want to know is what is causing the error to happen in the first place. Quote
Lanc1988 Posted February 25, 2004 Author Posted February 25, 2004 maybe it would be easiest if someone made a quick project in which it works and then posts it here so I can figure out how to get mine to work by looking at the code for it. Quote
Administrators PlausiblyDamp Posted February 25, 2004 Administrators Posted February 25, 2004 Is this a windows or web app? If windows then in the Catch bit do something like Catch ex as exception MessageBox.Show(ex.tostring()) end try if a web app then just display ex.ToString on a label on the webpage to see the error. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Lanc1988 Posted February 26, 2004 Author Posted February 26, 2004 ok, now it says "The Server rejected the sender address" Quote
Lanc1988 Posted February 26, 2004 Author Posted February 26, 2004 Ok I have everything working but i have one question: On the smtp server part, what am I suppose enter? Do I enter mine like I have it, or will it then not work on peoples computers that dont have the same internet as me? Do I need to replace it with something that will gather their smtp server address from their computer? Quote
Lanc1988 Posted February 26, 2004 Author Posted February 26, 2004 anyone know if it will work for everyone?? or do i need to put some kind of code to gahter it from their computer Quote
Administrators PlausiblyDamp Posted February 27, 2004 Administrators Posted February 27, 2004 (edited) What are you trying to do? If the server rejects the address then there is a good chance you are trying to send e-mails either from a server you shouldn't or to a server that doesn't want your e-mails. Any chance you could give a bit more detail? Edited May 4, 2007 by PlausiblyDamp Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Lanc1988 Posted February 27, 2004 Author Posted February 27, 2004 This part of the code: System.Web.Mail.SmtpMail.SmtpServer = "smtp.charter.net" Will the smtp.charter.net work for anyone who uses the form? Cuz it works for me, but its my smtp server.. Quote
Lanc1988 Posted February 27, 2004 Author Posted February 27, 2004 I was having someone test that part of my program with the submit code and they got the following error: System.PlatformNotSuppoortedException: this operation requires windows nt, 2000, xp. at System.Web.SmtpMail.Send(MailMessage message) at Runescape_sidekick.frmSubmit. Button1_Click(object sender, Event args e) Is there a way to make this code compatible with windows 98 also? Maybe I need to add something to my deployment project like a .dll or a resource so that it will work? Quote
Lanc1988 Posted February 27, 2004 Author Posted February 27, 2004 maybe if I add the "system.web.dll" file to the directory where my program starts up? Quote
Lanc1988 Posted February 27, 2004 Author Posted February 27, 2004 i am convinced it has to be the smtp server that I entered, since it is my server it is only working on people who have the same internet as me... so can anyone think of a way to get around this?? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.