Send current record via email

YNWA

Registered User.
Local time
Today, 15:58
Joined
Jun 2, 2009
Messages
905
Hi, I have a form set up, all working fine.

Now I want to add a button to the form so you click the button and it sends the current form data via email to someones email address that would have to be entered manually in Outlook.

I have a table consisting of the following fields...

referenceID - gives each record entered a unique ID
Request From - text field to enter the persons name who sent the request
Date of Request - Date field to enter date you received the request
Request Area - Memo field but on form it is a combo box to select a specific area from another table.
Brief Summary of Request - Memo field to enter what the request was asking for
Lead Analyst - Text field but drop down box on form to select one employees name from
Date Response Sent - Date field to enter a date you responded to the request
Date for Completion - Date field that autocalculates a date 14 days on based on date response sent
Comment/Action Taken - Memo field to detail what action was done for the request
Date COmpleted - Date field to enter a date you completed the request.

Now I just want a simply button that the user of the form clicks, and it will pop up with an Outlook email message with all the details of the current form/record in, so the user can enter the email address of the person who sent the request and send it to them detailing their referenceID etc.. which is useful for them incase they have any queries etc...

Is this possible? Or a better way of doing things?

Basically I want to send a response to someones email address which includes all the details the user of the form enters.

Cheers
Will
 
Create a button on your form called eMail. In the "On Click" event enter the following...

Code:
Private Sub eMail_Click()
    Dim olapp As Outlook.Application
    Dim olNewMail As Outlook.MailItem
    Dim eTo, eSubject, ebody As String 
    eTo = ""
    eSubject = "Subject" ' set to your own stuff
    ebody = "Email Body" ' set to your own stuff
    Set olapp = New Outlook.Application
    Set olNewMail = olapp.CreateItem(olMailItem)
    olNewMail.To = eTo
    olNewMail.Subject = eSubject
    olNewMail.Body = ebody
    olNewMail.Display
End Sub

You will need to plug in your own data and set up an error handler.

If you like this then don't forget to tip the scales in my favour.
 
I use a Word doc to form the background or body of the email and Access has inserted data from the record's text boxes to the Word doc bookmarks.

The first section in bold is where the data is being inserted into Word. The second section in bold is where it is using Access text box values for the Subject and Email address.

Dim OutMail As Object
Dim OutApp As Object
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
Dim wd As Word.Application
Dim doc As Word.Document
Dim WordRange As Word.Range
Dim Itm As Object
Dim ID As String
Dim blnWeOpenedWord As Boolean
On Error Resume Next
Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
blnWeOpenedWord = True
End If
Set doc = wd.Documents.Open _
(FileName:="c:\Letters\SoftwareSolutions3.doc")
Set WordRange = doc.GoTo(What:=wdGoToBookmark, Name:="a1")
WordRange.InsertBefore Nz([Forms]![PrintAndClose]![Notes], "")

Set WordRange = doc.GoTo(What:=wdGoToBookmark, Name:="Name")
WordRange.InsertBefore Nz([Forms]![PrintAndClose]![NameNotes], "")
doc.wdSaveChanges
Set Itm = doc.MailEnvelope.Item
With Itm
.To = Forms!PrintAndClose!A4
.Subject = [Forms]![PrintAndClose]![Text446]
.Save
ID = .EntryID
End With
Set Itm = Nothing
Set Itm = Outlook.Application.Session.GetItemFromID(ID)
Itm.Send
doc.Close wdDoNotSaveChanges
If blnWeOpenedWord Then
wd.Quit
End If
Set doc = Nothing
Set Itm = Nothing
Set wd = Nothing
 
I am still getting a compile error that says user defined type not defined
please help

Create a button on your form called eMail. In the "On Click" event enter the following...

Code:
Private Sub eMail_Click()
    Dim olapp As Outlook.Application
    Dim olNewMail As Outlook.MailItem
    Dim eTo, eSubject, ebody As String 
    eTo = ""
    eSubject = "Subject" ' set to your own stuff
    ebody = "Email Body" ' set to your own stuff
    Set olapp = New Outlook.Application
    Set olNewMail = olapp.CreateItem(olMailItem)
    olNewMail.To = eTo
    olNewMail.Subject = eSubject
    olNewMail.Body = ebody
    olNewMail.Display
End Sub

You will need to plug in your own data and set up an error handler.

If you like this then don't forget to tip the scales in my favour.
 
I seem to recall getting a similar error when setting up my e-mail function and it had to do with referencing the correct library. Try the steps below and see if it helps...

Extracted from http://www.jephens.com/2007/05/13/how-to-send-e-mail-from-ms-access-using-outlook

1. In the module, click on Tools then References

2. Scroll down the list and place a checkmark next to Outlook x.0 Object Model (for Outlook 98 it is version 8.0, Outlook 2000 is version 9.0, Outlook 2002/XP is version 10.0)

3. If it wasn't already checked near the top, scroll down a little bit more and check Microsoft DAO 3.x Object Library

4. Scroll down a little bit more and check Microsoft Scripting Runtime

5. Click OK to close that window.
 
Hi,

This is great.

I can get this to work, except my Memo field. I cannot use text fields because they are too small. But even if I put less than 255 characters in a memo field, the email just displays the name of the Table instead of the contents of the Memo field.

Can anyone help??

Thanks!!!
 

Users who are viewing this thread

Back
Top Bottom