SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Sending Email

  1. #1
    SitePoint Enthusiast eneza's Avatar
    Join Date
    Feb 2009
    Location
    Philippines
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Sending Email

    I tried a script using System.Net.Mail, and configuring some lines in the web.config.

    Well what happened is that it only sends mail on the address you configured in the web.config. What I am trying to do is I want to send a copy to the client who send an inquiry.

    One copy to me and One copy to the person who sends an inquiry.

    Thanks

  2. #2
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Show your code.

  3. #3
    SitePoint Enthusiast eneza's Avatar
    Join Date
    Feb 2009
    Location
    Philippines
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question

    Code:
    <mailSettings>
          <smtp>
            <network host="HOSTNAME" port="portnumber" userName="username" password="password"/>
            
          </smtp>
        </mailSettings>
    This is from WEB.CONFIG

    This is EmailAdmin.vb
    Code ASP:
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Data.OleDb
    Imports System.Net.Mail
    Imports Microsoft.VisualBasic
     
    Public Class EmailAdmin
        Public Function SendMail(ByVal FromMail As String, ByVal EmailBody As String) As MailMessage
            Const ToAddress As String =  "myemail@hostfromwebconfig"
            Dim mm As New MailMessage(FromMail, ToAddress)
            mm.Subject = "INQUIRY FROM WEBSITE"
            mm.Body = EmailBody
            mm.IsBodyHtml = False
            Return mm
        End Function
     
        Public Function SendInquirer(ByVal Inq_Name As String, ByVal ToInquirer As String, ByVal Tick As String) As MailMessage
            Const AdminEmail As String = "myemail@hostfromwebconfig"
            Dim MailMessage As String = "WELCOME " & Inq_Name & "," & _
            "<p>Your Inquiry has been forwarded and will be reviewes</p>" & _
            "YOUR TICKET NUMBER : " & Tick & " " & _
            "Thank for sending an inquiry this will help us improve our service to you" & _
            "Regards," & _
            "Miletrix Trading Inc." & _
            "Please do not reply this is server generated email. Thank You"
     
     
            Dim inq_mail As New MailMessage(AdminEmail, ToInquirer)
     
            inq_mail.Subject = "THANKS FOR INQUIRING"
            inq_mail.Body = MailMessage
            inq_mail.IsBodyHtml = False
     
            Return inq_mail
        End Function
     
     
    End Class

    This will trigger the send
    Code ASP:
     Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
            Dim CLS_Connect As New WebConnection
            Dim CLS_MailAdmin As New EmailAdmin
     
            Dim DS_Connect As New DataSet
            Dim SendMail As New SmtpClient
            'Dim STR_INS_Insert As String
     
     
            If Page.IsValid Then
                valCaptcha.Visible = True
                valCaptcha.Text = "YOUR INQUIRY SUCCESSFULLY SUBMITTED"
                valCaptcha.ForeColor = Drawing.Color.Blue
     
                SendMail.Send(CLS_MailAdmin.SendMail(txtEmail.Text, txtInquiry.Text))
                SendMail.Send(CLS_MailAdmin.SendInquirer(txtName.Text, txtEmail.Text, GenerateTicket()))
     
     
     
     
     
                txtEmail.Text = ""
                txtInquiry.Text = ""
                txtName.Text = ""
     
     
            Else
                valCaptcha.Visible = True
     
                valCaptcha.Text = "INVALID CAPTCHA CODE"
                valCaptcha.ForeColor = Drawing.Color.Red
     
            End If
        End Sub

    It practically sends to my email.... see the config........
    but not to the inquirer's email

    Thanks!

  4. #4
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Slightly off-topic, but when I click the link in your signature, NOD32 gave me this warning:



    What do you have going on over there?

  5. #5
    SitePoint Enthusiast eneza's Avatar
    Join Date
    Feb 2009
    Location
    Philippines
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Quote Originally Posted by FFCus View Post
    Slightly off-topic, but when I click the link in your signature, NOD32 gave me this warning:



    What do you have going on over there?
    Hmmm..... but please be calm, I am no virus spreader or something. It is hosted in a free hosting and under co.cc domain.

    but it should be...
    Attached Images Attached Images

  6. #6
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Back to your question...are the smtp server settings in web.config correct? Incorrect settings can allow local mail to go through but fail when sending to another server.

    Can you try a simple test with this code? Send it to an account that isn't local on the server.

  7. #7
    Chive On FFCus's Avatar
    Join Date
    Feb 2006
    Location
    Connecticut
    Posts
    542
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by eneza View Post
    Hmmm..... but please be calm, I am no virus spreader or something. It is hosted in a free hosting and under co.cc domain.
    I wasn't implying that you were a bad guy! I've actually never run into a site that my AV blocked me out of before.

    Those co.cc domains sure have a bad reputation!

  8. #8
    SitePoint Enthusiast eneza's Avatar
    Join Date
    Feb 2009
    Location
    Philippines
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by FFCus View Post
    I wasn't implying that you were a bad guy! I've actually never run into a site that my AV blocked me out of before.

    Those co.cc domains sure have a bad reputation!

    It's really quite an old domain..... even google blocked the co.cc domains.
    Hopefully will have a decent dot com sooner.....

    Thanks for understanding man.

  9. #9
    SitePoint Enthusiast eneza's Avatar
    Join Date
    Feb 2009
    Location
    Philippines
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    THIS THREAD IS SOLVED!!!! Will share the solution later after I test it more.

    Thanks For The Reply!
    FFCus see you 'round

  10. #10
    Non-Member
    Join Date
    Oct 2011
    Location
    Noida,IN
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    great such effect the tools send the mail first you can add
    system.net.mail
    then web.config create the connection the and local host name and username and password name
    then define the alias of the connection in the code then work your code manually send the mail

  11. #11
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by eneza View Post
    THIS THREAD IS SOLVED!!!! Will share the solution later after I test it more.

    Thanks For The Reply!
    FFCus see you 'round
    Well what was the solution? You said you would share it 2 months ago. Have you tested anything yet?

  12. #12
    SitePoint Enthusiast eneza's Avatar
    Join Date
    Feb 2009
    Location
    Philippines
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by KJ82 View Post
    Well what was the solution? You said you would share it 2 months ago. Have you tested anything yet?
    Im happy this morning until I saw this reply...... Do I owe you something?
    Code:
    Imports System.Web
    Imports System.Net.Mail
    Imports System.Net.Mail.SmtpClient
    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Data.OleDb
    IMPORT EVERYTHING.

    Code:
    Protected Sub btnSend_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSend.Click
            Dim CLS_MailAdmin As New EmailAdmin
            Dim SendMail As New SmtpClient
            Dim strGENTick As String
            'Dim STR_INS_Insert As String
    
    
    
            If Page.IsValid Then
                valCaptcha.Visible = True
                valCaptcha.Text = "YOUR INQUIRY SUCCESSFULLY SUBMITTED"
                valCaptcha.ForeColor = Drawing.Color.Blue
                strGENTick = GenerateTicket()
                CLS_MailAdmin.SaveInquiry(strGENTick, txtName.Text, txtEmail.Text, txtInquiry.Text, Now)
    
                Dim SmtpClient As New SmtpClient("ip address")
                SmtpClient.Credentials = New Net.NetworkCredential("username", "password")
                SmtpClient.Send(CLS_MailAdmin.SendInquirer(txtName.Text, txtEmail.Text, strGENTick))
    
                
    
    
                txtEmail.Text = ""
                txtInquiry.Text = ""
                txtName.Text = ""
    
    
            Else
                valCaptcha.Visible = True
    
                valCaptcha.Text = "INVALID CAPTCHA CODE"
                valCaptcha.ForeColor = Drawing.Color.Red
    
            End If
        End Sub
    This where you hit send.


    Code:
     Public Function SendInquirer(ByVal Inq_Name As String, ByVal ToInquirer As String, ByVal Tick As String) As MailMessage
    
            Dim MailMessage As String = "<p>WELCOME " & Inq_Name & ",</p>" & _
            "<p>Your Inquiry has been forwarded and will be reviewed</p>" & _
            "<br /><br />" & _
            "<p>YOUR TICKET NUMBER : " & Tick & "</p> " & _
            "<br /><br />" & _
            "<p>Thank you for sending an inquiry this will help us improve our service to you </p>" & _
            "<br />" & _
            "<p>Regards,</p>" & _
            "<p>COMPANY NAME</p>" & _
            "<em>Please do not reply this is server generated email. Thank You </em>"
    
            Dim inq_mail As New MailMessage("email admin", ToInquirer)
    
            inq_mail.Subject = "THANKS FOR INQUIRING"
            inq_mail.Body = MailMessage
            inq_mail.IsBodyHtml = True
    
            Return inq_mail
        End Function
    THEN THE MESSAGE

    Experiment more..... Thanks for the replies of nice people before the reply of the above.


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
  •