Des Ann
asked on
Sending E-mail ASP.Net
I have a page in my website that sends email using gmail (Contact Us)
it's ok when I run it locally, but after I upload to my webhost (Godaddy) there's an error:
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
When I researched it, the answer that I've got is to make use of javascript instead of Message Box but I didn't put any message box in my code.
it's ok when I run it locally, but after I upload to my webhost (Godaddy) there's an error:
Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
When I researched it, the answer that I've got is to make use of javascript instead of Message Box but I didn't put any message box in my code.
Pls post the code you are trying?
ASKER
The error that i posted above is already gone...
and just like I said it runs locally but when I uploaded it to godaddy it doesn't work anymore.
This is my code:
Imports System.Configuration
Imports MySql.Data.MySqlClient
Imports System.Net.Mail
Partial Public Class frmContactUs
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblResult.Text = ""
End Sub
Private Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim msg As New MailMessage
Dim smtp As New SmtpClient
Try
msg.To.Add("sample@website .com")
msg.From = New MailAddress("sample@gmail. com", "Contact Us")
msg.Subject = txtSubject.Text
msg.Body = "From: " & txtName.Text & vbNewLine & "E-mail address: " & txtEmail.Text & vbNewLine & vbNewLine & txtMessage.Text
smtp.Host = "smtp.gmail.com"
smtp.Port = "587"
smtp.EnableSsl = True
smtp.Credentials = New Net.NetworkCredential("sam ple@gmail. com", "samplePassword")
smtp.Send(msg)
lblResult.Text = "Your message has been sent!"
Catch ex As Exception
lblResult.Text = "Your message failed to send, please try again."
Exit Sub
End Try
End Sub
End Class
and just like I said it runs locally but when I uploaded it to godaddy it doesn't work anymore.
This is my code:
Imports System.Configuration
Imports MySql.Data.MySqlClient
Imports System.Net.Mail
Partial Public Class frmContactUs
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
lblResult.Text = ""
End Sub
Private Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
Dim msg As New MailMessage
Dim smtp As New SmtpClient
Try
msg.To.Add("sample@website
msg.From = New MailAddress("sample@gmail.
msg.Subject = txtSubject.Text
msg.Body = "From: " & txtName.Text & vbNewLine & "E-mail address: " & txtEmail.Text & vbNewLine & vbNewLine & txtMessage.Text
smtp.Host = "smtp.gmail.com"
smtp.Port = "587"
smtp.EnableSsl = True
smtp.Credentials = New Net.NetworkCredential("sam
smtp.Send(msg)
lblResult.Text = "Your message has been sent!"
Catch ex As Exception
lblResult.Text = "Your message failed to send, please try again."
Exit Sub
End Try
End Sub
End Class
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.