CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2011
    Posts
    2

    Cool automatically send an email to the email address in the body of an Outlook email

    Using Outlook 2010, I receive about 5 emails a day from the same sender everyday. These emails contain only one email in the body of the email that I am manually copy and paste into a new email and send myself. I am thinking that with Outlook Rules and Visual Basic I can make it so when I receive the email from a particular sender Outlook can automatically find or detect and extract the email in the body and auto send a template email to that email address.

    I hope I am making sense but to keep it simple, basically, I want to auto email the email address located in the body of an outlook email and not the sender.

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: automatically send an email to the email address in the body of an Outlook email

    Your post is unclear in one place it sounds like you want to send the body of an email you have received to yourself and in another place it sounds like you are wanting to extract an email address from the message and send to that address.

    The first step in getting the help you seek is to clearly phrase the question.

    You should also show the code that you have written and explain where you are having a problem.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: automatically send an email to the email address in the body of an Outlook email

    Re: automatically send an email to the email address in the body of an Outlook email

    Microsoft blocked access to that in Office 2007 (I believe), after script-kiddies used other peoples OUTLOOK account to send 100's of emails per minute. Now there's a rule. Post more than every 5 minutes, and it will countdown.
    There used to be a 'TOOL' that would click the button, when it appeared, thereby bypassing the TIMER.

    Up to the current day, MS remedied that, as well...

    Most ISP's allow you to SEND MAIL directly from THEIR SERVER. That's the right way.
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  4. #4
    Join Date
    Jul 2011
    Posts
    2

    Re: automatically send an email to the email address in the body of an Outlook email

    the 2nd option you posted is what I was trying to explain.

  5. #5
    Join Date
    Dec 2008
    Location
    Step Into(F11)
    Posts
    465

    Talking Re: automatically send an email to the email address in the body of an Outlook email

    Using Outlook 2010, I receive about 5 emails a day from the same sender everyday. These emails contain only one email in the body of the email that I am manually copy and paste into a new email and send myself. I am thinking that with Outlook Rules and Visual Basic I can make it so when I receive the email from a particular sender Outlook can automatically find or detect and extract the email in the body and auto send a template email to that email address.

    I hope I am making sense but to keep it simple, basically, I want to auto email the email address located in the body of an outlook email and not the sender.
    Can you post the code please ?it is much better to understand the
    forums members of Codeguru .

  6. #6
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: automatically send an email to the email address in the body of an Outlook email

    This works on my site (using Net 2.0) and ASP.Net

    Code:
    Imports System.Net.Mail
    Imports System.String
    Imports System
    Imports System.Net
    Imports System.IO
    Imports System.Text
    Imports Microsoft.VisualBasic
    
    
    Partial Class contact
    	Inherits System.Web.UI.Page
    
    	Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
    		Try
    			If Request.UrlReferrer.Host <> Request.Url.Host Then
    				Return
    			End If
    
    			Dim msg As New MailMessage
    			msg.To.Add(ConfigurationManager.AppSettings("MailingListEmailTo").ToString)
    			msg.From = New MailAddress(ConfigurationManager.AppSettings("SiteEmail").ToString)
    			msg.Subject = "A contact form has been submitted"
    			msg.IsBodyHtml = True
    			Dim out As String = ""
    			If Len(txtAdditional.Text) > 300 Then
    				out = Left(txtAdditional.Text, 300)
    			Else
    				out = txtAdditional.Text
    			End If
    			msg.Body = "A new contact form was filled out on the website.<br><br>" & _
    			  Now.ToString & "<br><br>" & _
    			  "Name: " & txtName.Text & "<br>" & _
    			  "Company: " & txtCompany.Text & "<br>" & _
    			  "Email: " & txtEmail.Text & "<br>" & _
    			  "Address: " & txtAddress.Text & "<br>" & _
    			  "Phone: " & txtPhone.Text & "<br>" & _
    			  "Preferred contact method: " & ddlContactMethod.SelectedItem.ToString & "<br>" & _
    			  "Primary business: " & txtBusiness.Text & "<br>" & _
    			  "Time frame: " & txtTimeframe.Text & "<br>" & _
    			  "Heard about from: " & ddlHearAbout.SelectedItem.ToString & "<br>" & _
    			  "Additional: " & out
    			Dim smtpClient As New SmtpClient
    			smtpClient.Host = ConfigurationManager.AppSettings("SMTPServer")
    			smtpClient.Send(msg)
    			Response.Redirect("default.aspx")
    		Catch ex As Exception
    		End Try
    	End Sub
    End Class
    Click the button, and I get an email (from my site!)
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured