Cann't send email and attachment thru asp.net 2003 using smptserver="localhost" [modified]
-
Hi My requirement is i have an application form which has entries like name,dob,qualification,exp and upload resume(file field). when somebody fill this form, upload his resume and press submit ,i want these details and resume to get in my yahoomails inbox. but when i try this with local host it doesn't work i hve given the ip address in default smptservers relay button. i am using asp.net 2003 can anybody pls help me why i am not getting this correctly.Below i am giving the code i hve used Imports System Imports System.Data.OleDb Imports System.web Imports System.IO Imports System.Web.Mail Imports System.Web.SessionState Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Function FncSubmit() Dim szSQL As String Dim objdr As OleDbDataReader Dim icnt As Integer Dim sapplnno As String Dim szFileBiodata As String Dim szfile As String Dim iapplnno As Integer Dim attach1 As String Dim objEmail As New MailMessage objEmail.To = "abc@yahoo.co.in" objEmail.From = txtEmail.Text objEmail.Subject = txtName.Text & "," & txtQualif.Text & ", " & txtExp.Text objEmail.Body = "hi" If Not file1.PostedFile Is Nothing Then Dim attFile As HttpPostedFile = file1.PostedFile Dim attachFileLength As Integer = attFile.ContentLength If attachFileLength > 0 Then szfile = Path.GetFileName(file1.PostedFile.FileName) file1.PostedFile.SaveAs(Server.MapPath(szfile)) Dim attach As MailAttachment = New MailAttachment(Server.MapPath(szfile)) ' Attach the Newly created email attachment */ attach1 = szfile objEmail.Attachments.Add(attach) End If End If objEmail.Priority = MailPriority.High SmtpMail.SmtpServer ="localhost" Try SmtpMail.Send(objEmail) 'MessageBox.Show("Your feedback has been submitted.") MessageBox.Show("Your application is submitted") Catch exc As Exception MessageBox.Show("Failed to submit your feedback: ") 'MessageBox.Show(exc.ToString()) Response.Write(exc.ToString()) End Try If attach1 <> "" Then
-
Hi My requirement is i have an application form which has entries like name,dob,qualification,exp and upload resume(file field). when somebody fill this form, upload his resume and press submit ,i want these details and resume to get in my yahoomails inbox. but when i try this with local host it doesn't work i hve given the ip address in default smptservers relay button. i am using asp.net 2003 can anybody pls help me why i am not getting this correctly.Below i am giving the code i hve used Imports System Imports System.Data.OleDb Imports System.web Imports System.IO Imports System.Web.Mail Imports System.Web.SessionState Imports System.Collections Imports System.ComponentModel Imports System.Drawing Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Function FncSubmit() Dim szSQL As String Dim objdr As OleDbDataReader Dim icnt As Integer Dim sapplnno As String Dim szFileBiodata As String Dim szfile As String Dim iapplnno As Integer Dim attach1 As String Dim objEmail As New MailMessage objEmail.To = "abc@yahoo.co.in" objEmail.From = txtEmail.Text objEmail.Subject = txtName.Text & "," & txtQualif.Text & ", " & txtExp.Text objEmail.Body = "hi" If Not file1.PostedFile Is Nothing Then Dim attFile As HttpPostedFile = file1.PostedFile Dim attachFileLength As Integer = attFile.ContentLength If attachFileLength > 0 Then szfile = Path.GetFileName(file1.PostedFile.FileName) file1.PostedFile.SaveAs(Server.MapPath(szfile)) Dim attach As MailAttachment = New MailAttachment(Server.MapPath(szfile)) ' Attach the Newly created email attachment */ attach1 = szfile objEmail.Attachments.Add(attach) End If End If objEmail.Priority = MailPriority.High SmtpMail.SmtpServer ="localhost" Try SmtpMail.Send(objEmail) 'MessageBox.Show("Your feedback has been submitted.") MessageBox.Show("Your application is submitted") Catch exc As Exception MessageBox.Show("Failed to submit your feedback: ") 'MessageBox.Show(exc.ToString()) Response.Write(exc.ToString()) End Try If attach1 <> "" Then
-
Why did you assign both IP and localhost to SmtpMail.SmtpServer in the line SmtpMail.SmtpServer ="localhost"' "127.0.0.1"?. Use either one. Also post the error message, if this is not working.
-
i hve gven only local host. there is no error message shown but iam not getting email in my inbox
use smtp.net.mail make object of SmtpClient smtp1 = new SmtpClient(); smtp1.Send(objMail); objMail containt the details of Mailt TO, Mail From, Body etc . use this u can easily send the mail. Regards Keyur