Insert fields from Access into Email body 
Author Message
 Insert fields from Access into Email body

I am aware of how you can use SendObject to attach any Access object to an
email. But is there away to specify the results of a query or the actual
table records into the body of the email itslef (even using VBA) ??

Thank you

Denis



Tue, 07 Oct 2003 23:23:29 GMT  
 Insert fields from Access into Email body
No, but you could do this through a report i.e. format the results of
a query to a report and export the report through an e-mail!

On Fri, 20 Apr 2001 16:23:29 +0100, "Denis Vaughan"

Quote:

>I am aware of how you can use SendObject to attach any Access object to an
>email. But is there away to specify the results of a query or the actual
>table records into the body of the email itslef (even using VBA) ??

>Thank you

>Denis



Tue, 07 Oct 2003 23:47:11 GMT  
 Insert fields from Access into Email body
Hi Denis,

You don't say if you intend to use a particular e-mail client, or if
this code must be generic to any e-mail client...

Some month ago, I've answered a quation that needed to send a table
with Outlook as an atachment... I'm leaving the code here, maybe it
can help you somehow, beware that this is air-code, if the person that
would used this code made any change to it, I'm not aware, and I never
used it in real app's.

Sub CreateTableToSend()
Dim db As Database
Dim rst As Recordset
Dim intFileNumber As Integer
Dim strFilePath As String
Dim strLineToPrint As String
Dim fld As Field
Const cQuotes = """"

intFileNumber = FreeFile
strFilePath = "C:\Work\Tes{*filter*}vio.txt"

Set db = DBEngine(0)(0)
Set rst = db.OpenRecordset("tblTesteNull")
rst.MoveFirst

Open strFilePath For Append As #intFileNumber
Do While Not rst.EOF
  For Each fld In rst.Fields
    Select Case fld.Type
      Case dbText
        strLineToPrint = strLineToPrint & cQuotes & fld.Value &
cQuotes & ";"
      Case dbDate
        strLineToPrint = strLineToPrint & "#" & Format(fld.Value,
"dd-mm-yyyy") & "#" & ";"
      Case dbLongBinary, dbMemo
      Case Else
        strLineToPrint = strLineToPrint & fld.Value & ";"
      End Select
  Next fld
  rst.MoveNext
  Print #intFileNumber, strLineToPrint; vbCr
  strLineToPrint = vbNullString
Loop
Close #intFileNumber

Call sendtable(strFilePath, False)

End Sub

Sub SendTableToOutLook(strAttachmentPath As String, fDisplayMsg As
Boolean)
    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient
    Dim objOutlookAttach As Outlook.Attachment
    'N?o te esque?as de fazer a referencia Type Library do Outlook

    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
         Set objOutlookRecip = .Recipients.Add("Nuno Clara")
         objOutlookRecip.Type = olTo
        .Subject = "Isto um teste com Microsoft Outlook"
        .Body = "Junto envio a Tabela." & vbCrLf & vbCrLf
        If Not dir(strAttachmentPath) = vbNullString Then
            Set objOutlookAttach = .Attachments.Add(strAttachmentPath)
        End If
        For Each objOutlookRecip In .Recipients
            objOutlookRecip.Resolve
        Next
        ' Mostra a msg ou envia?
        If fDisplayMsg Then
            .Display
        Else
            .Send
        End If
    End With
    Set objOutlook = Nothing
End Sub

On Fri, 20 Apr 2001 16:23:29 +0100, "Denis Vaughan"

Quote:

>I am aware of how you can use SendObject to attach any Access object to an
>email. But is there away to specify the results of a query or the actual
>table records into the body of the email itslef (even using VBA) ??

>Thank you

>Denis

---------
Pedro Gil
http://www.*-*-*.com/

DDPI
http://www.*-*-*.com/
https://sourceforge.net/projects/ddpi/



Wed, 08 Oct 2003 01:19:36 GMT  
 Insert fields from Access into Email body
Denis,

SendObject attaches the access objects to the mail message rather than
including them in the body.  If you want extensive information to be
included in the body of the message, you can use our IDSMail component
like this:

Dim idsMail as Object
Set idsMail = CreateObject("IDSMailInterface.Server")
Set idsMail = CreateObject("IDSMailInterface32.Server")
idsMail.ObjectKey = "ABC123"
idsMail.MailSystem =IDSM_SYS_SMTP_POP
idsMail.SMTPServer = "myprovider.com"
idsMail.NewMessage



idsMail.Subject = "Database Info"
idsMail.Message = "Put your data here."
idsMail.Send

You would write VBA code to loop through your recordset, formatting a
text string with the data you wanted to include in the body, in whatever
format you want.  Then you set your text string as the value of the
Message property.  Or, you could format your data as HTML, and use the
IDSMail AddAlternative method to include your HTML as the body of the
message.

For more info on IDSMail, go to http://www.intuitive-data.com

--
Regards,

Eric June
Intuitive Data Solutions

----- IDSMail - The Universal E-mail Component  --------
Send/Rcv E-mail *EASILY* through SMTP/POP, VIM,
MAPI, MHS, Banyan VINES, Active Messaging, & CDO:
http://www.intuitive-data.com/idsmail.htm
----------------------------------------------------------------------------



Wed, 08 Oct 2003 02:25:17 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. inserting date within email body/subject line

2. Inserting text to email body (not a signature)

3. Inserting text to email body

4. Problem Inserting Text Into Email Body Using VB5

5. help,how to insert a picture into the body of an email

6. Mail Body field to Access memo field

7. Code to extract a formatted message body of an email into an access Database

8. Store sender and body of selected email to Access database

9. Formatting email body using VBA in Access

10. Formatting email body using VBA in Access

11. Newbie Emailing text file into body of Email

12. Insert Field Value In Email Subject Line

 

 
Powered by phpBB® Forum Software