Results 1 to 4 of 4

Thread: Sending email from asp.net 2.0

  1. #1
    Join Date
    Jun 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Sending email from asp.net 2.0

    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

  2. #2
    Join Date
    Feb 2004
    Posts
    4,877
    Thanks
    2
    Thanked 134 Times in 113 Posts

    Default

    Why isn't it working, is there an error?
    Warren Ashcroft
    Red Fox UK Limited - Pioneers in Internet Technology
    http://www.redfoxuk.com
    w.ashcroft [at] redfoxuk.com

    NOTE: Forum Private Messaging should not be used to contact staff with support queries.

  3. #3
    Join Date
    Jun 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Warren,

    Many thanks for your prompt reply

    nope, no error at all. Which is why im so bafflled lol

    I have a try catch around the mail send, with a response.write back to the screen and its not catching anything. I cant see whats wrong as it is an exact copy of what I had on the other domain.

    Any ideas?

    Thanks again

  4. #4
    Join Date
    Jun 2005
    Posts
    1,080
    Thanks
    4
    Thanked 15 Times in 15 Posts

    Default

    A couple of things:

    1). Is the Smtp server configured in the web.config correctly?

    2). Is the message getting caught by spam filters?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Asp.Net 2.0 email contact forms
    By Furzetech in forum ASP.NET
    Replies: 1
    Last Post: 13th February 2007, 05:23 PM
  2. ASP.net 2.0
    By JohnnyW in forum Sales and Service Feature Enquiries
    Replies: 17
    Last Post: 8th November 2005, 02:01 PM
  3. asp.net sending email
    By creativeworks in forum ASP.NET
    Replies: 5
    Last Post: 5th July 2005, 06:58 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •