Attachments from query into mail

P

padsoft

I am trying to add a not saved attachment no a mail.
This attachement is a query.
This is the sample code I want to use:
Dim objolk As Outlook.Application
Dim objMailItem As Outlook.MailItem
Dim olkNameSpace
Set objolk = New Outlook.Application
Set olkNameSpace = objolk.GetNamespace("MAPI")
Set objMailItem = objolk.CreateItem(olMailItem)
objMailItem.To = "[email protected]"
objMailItem.Recipients.ResolveAll
objMailItem.Subject = "pl enter subject of the letter here"
objMailItem.CC = "Moderator"
objMailItem.Display
objMailItem.Body = " Welcome to Utter Access.com . Utter Access Rulez
&
objMailItem.attachement (The query I want to send)
objMailItem.Send

See also the sendobject code I use at this moment:
DoCmd.SendObject acSendTable, "T_YTI", acFormatXLS, mail1, mail2,
"Text """ & kantoor & """", Teksthead, False


Because I have created a loop inside the code, the query constantly ha
different values. These queries are sent to different adresses.

To be clear, the question is, how do I translate "acSendTable, "T_YTI"
acFormatXLS" into a objMailITem.attachement code??
 
A

Alex Dybenko

Hi,
you can docmd.outputto your query to whatever format you like (text,
snapshot, etc) and then attach result to your mail message
 
Top