Results 1 to 5 of 5
  1. #1
    jcbrackett is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    5

    Email to outlook based off fields in a form

    I have it set to where I can send an email and compile the subject and part of the body via clicking a button on the form. Problem is I have to manually enter the email address in the code and I want it done automatically via the combo box I have that updates my list box, also I want the list box data that is pulled to go into the body of the email as well. Here is the code that I have built thus far. The combo box only list the tech number but i have a query that references the tech number to the correct email address. Any help is greatly appreaciated!



    Private Sub Command12_Click()
    Dim subject As String, Body As String
    subject = [Text2]
    Body = [Text1] & Chr$(13) & [Text3] & Chr$(13)
    DoCmd.SendObject , "Send an email", acForm, "Email Receipint Here(want this to be automatically filled based of the value of the combo box), , , subject, Body, False
    End Sub

  2. #2
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Hmm I send form text into a different application. This MIGHT work, obviously change the ("frmMain") to the name of the form and .txtAccession to the name of your text field.. If it works please let me know .

    " & Forms("frmMain").txtAccession & ",

    edit - thinking about it the " & might not apply to your need. try this as well.

    Forms("frmMain").txtAccDate

  3. #3
    jcbrackett is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Where exactly would i add that code into mine?

  4. #4
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Sorry, Proving more difficult then I originally thought. I was able to find this code from microsoft, and I was able to generate emails.. however applying the form entry to the email is not working.

    http://msdn.microsoft.com/en-us/libr...ffice.11).aspx
    Last edited by redbull; 03-07-2012 at 11:39 AM. Reason: Code Tags

  5. #5
    jcbrackett is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    5
    Ok, so i can get it to email just fine and change to different recipients based off my combo box. What I can not get it to do is add the information that is in the list box to the body of the email as well. the list box is labeled as Text1. here is the code that i have.

    Private Sub Command12_Click()
    Dim subject As String, Body As String
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem

    On Error Resume Next
    Set OutApp = GetObject(, "Outlook.Application")
    If OutApp Is Nothing Then
    Set OutApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo 0

    Set OutMail = OutApp.CreateItem(olMailItem)

    With OutMail

    .To = Me.Combo0.Column(1)
    .subject = [Text2]
    .Body = [Text1] & Chr$(13) & [Text3] & Chr$(13)
    .Send
    End With

    Set OutMail = Nothing
    Set OutApp = Nothing

    End Sub

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Email and Outlook
    By Douglas Post in forum Programming
    Replies: 1
    Last Post: 02-13-2012, 02:57 PM
  2. email with outlook.application
    By JJCHCK in forum Access
    Replies: 5
    Last Post: 08-25-2011, 06:19 AM
  3. Replies: 2
    Last Post: 07-29-2011, 12:33 PM
  4. Send email from Access thru Outlook
    By ZMAN in forum Forms
    Replies: 2
    Last Post: 11-27-2010, 06:10 PM
  5. Exporting Outlook email addresses
    By noidea in forum Import/Export Data
    Replies: 0
    Last Post: 08-01-2009, 01:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums