Link to home
Start Free TrialLog in
Avatar of geekboysteves
geekboysteves

asked on

Open a web form (B) using VB code behind web form (A)?

I have a .aspx web form with VB code behind it and I'm using Visual Studio .NET 2003.  After the user clicks the [Submit] button, my code sends email with information from various controls on the form and that is working just fine...  But, then the form just sits there stupidly waiting for them to do it again apparently.

I want to open the typical "Thank you for submitting!" web page after the code sends the emails.

In VB code (again this code behind a .aspx web form) how do I open another web form (on the same web site)?

THANKS!
ASKER CERTIFIED SOLUTION
Avatar of Level10Access
Level10Access

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of geekboysteves
geekboysteves

ASKER

Worked like a charm!

    Private Sub Submit1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit1.ServerClick
        'send mail here
        Dim MyMessage As New System.Web.Mail.MailMessage
        MyMessage.From = "steve@yourdomainhere.com"
        MyMessage.To = "geekboysteves@yourdomainhere.com"
        MyMessage.Cc = "steve@yourdomainhere.com"
        MyMessage.Subject = "CSI Contact US"
        MyMessage.Body = Me.TEXTAREA1.Value
        System.Web.Mail.SmtpMail.SmtpServer = "smtp.yourdomainhere.com"
        System.Web.Mail.SmtpMail.Send(MyMessage)
        'Thanks Level10Access!
        Server.Transfer("ThankYou.aspx", False)
    End Sub
Pleasure's all mine
geekboysteves.  

What email smtp server did you use to send that message?  was it one of your own, as in a box you have personally or does someone else host it.

Reason i ask is because i am doing the same thing, but it is a server i dont own and i have to authenticate to it.

any ideas?

thanks
I was using my own box to send the mail at the time, but I gave up on that after I found it was taken over by spammers and decided to remove SMTP from my server and go crawling back to my hosting service.  Here's how I would do it now (we went back to an old Unix script to send mail becuase my hosting service is Unix not Windows).

Please forgive any "typos"--scanned and OCR-ed it this morning.

Page 282 Microsoft Visual Basic .NET Programmer's Cookbook

…However, there is a significant catch to using the SmtpMail class to send an e-mail message. This class requires a local SMTP server or relay server on your network. In addition, the SmtpMail class doesn't support authentication, so if your SMTP server requires a username and password, you won't be able to send any mail. To overcome these problems, you can use the CDOSYS component directly through COM interop (assuming you have a server version of Windows or Microsoft Exchange).

Here's an example that uses the CDOSYS component to deliver SMTP using a server that requires authentication:

Dim MyMessage As New CDO.Message()
Dim Config As new CDO.configuration()

'Specify the configuration.
Config.Fields(cdoSendusingMethod) = cdoSendusingPort Config.Fields(cdoSMTPserver) = “test.mailserver.com''
Config.Fields(cdoSMTPServerPort) = 25
Confjg.Fields(cdoSMPTAuthenticate) = cdoBasic
Config.Fields(cdoSendUserName) = ''username''
Config.Fields(cdoSendPassword) = ''password''
'update the configuration.
Config.Fields.update()
MyMessage.configuration = Config
' Create the message.
MyMessage.To = ''someone@somewhere.com''
MyMessage.From = ''me@somewhere.com''
MyMessage.Subject = ''Hello''
MyMessage.TextBody = ''This is the message!”
' Send the CDOSYS Message
MyMessage.send()

I am certain it will work for you.  Everything in that book is gold!
Steve
yeah thanks for the help.  It was also that my ISP made outgoing messages be sent through there SMTP server.

thanks