Hi all
Hope all is well, I had a page running on a domain with some code to send an email. I have since copied the code to another domain but i cant seem to send/receive any emails![]()
I read another thread that had diffrent method of how to send an email which I am willing to try out but before I do, can anyone tell me why this is not working?
Many thanks in advance for your help!
The source code is below:
Dim savePath AsString = "C:\temp\"
ProtectedSub Button1_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles Button1.Click
IfNot (uploadedFile.PostedFile IsNothing) Then
Dim postedFile = uploadedFile.PostedFile
Dim filename AsString = Path.GetFileName(postedFile.FileName)
Dim contentType AsString = postedFile.ContentType
Dim contentLength AsInteger = postedFile.ContentLength
postedFile.SaveAs(Server.MapPath("cv/" & filename))
Try
Dim m As Web.Mail.MailMessage = New Web.Mail.MailMessage
With m
.From = txtEmail.Text
.To = someone@somewhere.com
.Cc = ""
.Body = txtName.Text & " Would like to apply for: " & "<br /><Br />"
.Body &= "Role: " & lblJobTitle.Text & "<br /><Br />"
.Body &= "Location: " & LblLocation.Text & "<br /><Br />"
.Body &= "Salary: " & lblSalary.Text & "<br /><Br />"
.Body &= "************************************************* *****" & "<br /><Br />"
.Body &= "Applicants Comments: " & txtComments.Text
.Subject = txtName.Text & " Would like to send you an email"
.BodyFormat = MailFormat.Html
IfNot (uploadedFile.PostedFile IsNothing) Then
Dim myAttachment As MailAttachment = New MailAttachment(Server.MapPath("cv/" & filename))
.Attachments.Add(myAttachment)
EndIf
EndWith
SmtpMail.Send(m)
pnlSent.Visible = True
pnlApply.Visible = False
Catch ex As Exception
Response.Write(ex.message & "There was an error") ' Failed uploading file
pnlError.Visible = True
EndTry
EndIf
EndSub


Reply With Quote

Bookmarks