Link to home
Start Free TrialLog in
Avatar of Murray Brown
Murray BrownFlag for United Kingdom of Great Britain and Northern Ireland

asked on

ASP.net handle incoming emails in VB.net

Hi

I have worked out how to send an email from a website using VB.net code.
Now I need to manipulate replies to these emails using VB.net code.
How is this done? Code examples? Thanks
Avatar of kaufmed
kaufmed
Flag of United States of America image

You are aware that replies are going to go (provided you put in a valid address) to your email server, and not back to the web page, correct? Are you wanting to write a Windows service or some unattended application which will retrieve new emails from your email server?
Avatar of Murray Brown

ASKER

Yes I am aware of that and that is exactly what I want to do: retrieve emails from the server
Does your email server support either  POP(3) or IMAP?
I think POP3
I send mesages using the following code. My Web.Config also contains the markup below

    Public Sub SendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String, ByVal cc As String, ByVal subject As String, ByVal body As String)

        Try
            ' Instantiate a new instance of MailMessage
            Dim mMailMessage As New MailMessage()

            ' Set the sender address of the mail message
            mMailMessage.From = New MailAddress(from)
            ' Set the recepient address of the mail message
            mMailMessage.To.Add(New MailAddress(recepient))

            ' Check if the bcc value is nothing or an empty string
            If Not bcc Is Nothing And bcc <> String.Empty Then
                ' Set the Bcc address of the mail message
                mMailMessage.Bcc.Add(New MailAddress(bcc))
            End If

            ' Check if the cc value is nothing or an empty value
            If Not cc Is Nothing And cc <> String.Empty Then
                ' Set the CC address of the mail message
                mMailMessage.CC.Add(New MailAddress(cc))
            End If

            ' Set the subject of the mail message
            mMailMessage.Subject = subject
            ' Set the body of the mail message
            mMailMessage.Body = body

            ' Set the format of the mail message body as HTML
            mMailMessage.IsBodyHtml = True
            ' Set the priority of the mail message to normal
            mMailMessage.Priority = MailPriority.Normal

            'Dim Attach As Attachment = New Attachment(System.Web.HttpContext.Current.Server.MapPath("~/Temp/") & AttachFileName)

            'mMailMessage.Attachments.Add(Attach)

            ' Instantiate a new instance of SmtpClient
            Dim mSmtpClient As New SmtpClient()
            ' Send the mail message
            mSmtpClient.Send(mMailMessage)

        Catch ex As Exception
            Me.Label_Error.Text = ex.Message
        End Try
    End Sub

  <!-- Email **** Add the email settings to the <system.net> element -->
  <system.net>
    <mailSettings>
      <smtp from="info@smssend.co.za">
        <network host="localhost" port="25" userName="info@smssend.co.za" password="xer"/>
      </smtp>
    </mailSettings>
  </system.net>
  <!-- Email **** Add the email settings to the <system.net> element -->
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks very much