Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

  • Administrators
Posted

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?

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted
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.
Posted

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?

  • Administrators
Posted (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 by PlausiblyDamp

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

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..

Posted

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?

Posted
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??

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...