Results 1 to 10 of 10
  1. #1
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19

    Send Form Data in Email

    Hello,

    I am looking for information as to how to send form data in an email.

    For example, I'd like an email to be sent when a new record is added. I'd like to include the information entered into the form.



    I'd like another option that when a check box is selected and marks the record as complete, an email is sent with all of the complete information on the forum.

    I'd like to sent it straight in an email body rather than pdf.

    I understand this can be done with VBA but I am fairly new. Can someone point me in the direction of some information to help?

    Thank you,
    Mark

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you can make a report based on the form, or send an image of the form.
    make a button, to run macro:

    docmd.SendObject acSendForm ,"frmMyForm",acFormatPDF,sTo,,,sSubj,sBody

  3. #3
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    Thank you for the response. I do not want to use an image. I would just like to compile the fields from the form into the email body as text.

    I have been trying to get this to work, but being new to the coding side, I am sort of lost as to what to do?

    Dim stSendTo As String
    Dim stTransferDate As String
    Dim objMailItem As Outlook.MailItem
    Dim olkApp As Outlook.Application
    Dim olkNameSpace As Outlook.NameSpace

    'Send email
    Set olkApp = New Outlook.Application
    Set olkNameSpace = olkApp.GetNamespace(""MAPI"")
    Set objMailItem = olkApp.CreateItem(olMailItem)
    stTransferDate = Format(Now(), ""mm-dd-yyyy"")
    stSendTo = "examplee@mailaddress.co.uk"
    With objMailItem
    .To = stSendTo
    .Recipients.ResolveAll
    .Subject = ""Induction: A new record has been added. "" &
    stTransferDate
    .Body = ""A new record has been added to the Induction database.""
    .Send 'or Display
    .Save
    .Close (olSave)
    End With




    Any information that you can share, would be helpful.

    Thanks,

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    this is what PDFs are for. No code needed.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Build a variable and use it for the body:

    strBody = "Dear " & Me.NameTextbox & vbCrLf & "Blah blah" & Me.SomeOtherTextbox

    vbCrLf adds a line feed.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    Quote Originally Posted by pbaldy View Post
    Build a variable and use it for the body:

    strBody = "Dear " & Me.NameTextbox & vbCrLf & "Blah blah" & Me.SomeOtherTextbox

    vbCrLf adds a line feed.
    Can you please explain this a bit better?

    Do I assigned this code to an "On Insert" event or something? Or a button?

    What if I want to include all fields for a particular record?

    The following are the fields from my main table called InductionsNEW:

    InductionID
    DateEmployeed
    AddedBy
    FirstName
    Surname
    EmployeeNo
    Department
    DateStarted
    InductionBy
    HSEBy
    TrainingBy
    QualityBy
    SafetyItems
    TrainingItems
    CommunicationItems
    QualityItems
    HRItems
    IndType
    DateCompleted
    Approved
    Comments

    I would like to send an email after a new record has been inserted into the database.

    So the email should have all the fields listed above included and be sent to 4 particular people from Outlook.

    I am very new to VBA, so I am not sure really how to start this or approach this?

    Can you provide a few steps for me to follow or some information that can guide me in this?

    If it is easier to use a PDF, I wouldn't mind taking that route, but I would still need the PDF to be limited to the record that has been added to the database.

    Thank you.

  7. #7
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    Quote Originally Posted by ranman256 View Post
    this is what PDFs are for. No code needed.
    Would you be able to explain the steps to get the output I need?

    See my message in the next post to pbaldy.

    Thank you.

  8. #8
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Quote Originally Posted by DSProductionz View Post
    Can you please explain this a bit better?

    Do I assigned this code to an "On Insert" event or something? Or a button?

    What if I want to include all fields for a particular record?
    No, I'm saying to replace this line:

    Code:
    .Body = ""A new record has been added to the Induction database."" 
    with

    Code:
    Dim strBody As String
    strBody = "Dear " & Me.NameTextbox & vbCrLf & "Blah blah" & Me.SomeOtherTextbox
    .Body = strBody
    You can build strBody with pretty much as much text and as many fields from the form as you want.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  9. #9
    Join Date
    Aug 2017
    Location
    Batley, United Kingdom
    Posts
    19
    I am not sure if I am missing something here? Obviously being new to this side of things, I have no idea where to start?

    I see the code, but I am not sure what to do with it?

    Any advice please?

    Thanks.

  10. #10
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    It would go here, perhaps behind a button to test:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 4
    Last Post: 07-12-2018, 05:38 AM
  2. Create button to send email based on data in tbl
    By kiwikiki718 in forum Programming
    Replies: 12
    Last Post: 04-09-2017, 05:31 PM
  3. Replies: 3
    Last Post: 12-28-2015, 04:11 PM
  4. Replies: 1
    Last Post: 03-23-2015, 05:59 PM
  5. Replies: 9
    Last Post: 10-09-2009, 08:15 AM

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
  •  
Other Forums: Microsoft Office Forums