Export query to xml and mail that.

P

pnp

Hi

I have a small problem figuring out how to do <subject>.

What i would like to happen is that I have a query defined in my Access
database, when i push a button, I would like to save this query as xml and
send it as an attachment to an email.

I can do just that, just sending data as Excel instead of XML. By using the
macro SendObject I can select a query and select type. But here I can't
select XML.

If i select export on the query I can select to XML, but how do i automate
this, and put it in a mail?

Hope somebody can help me.

/Anders
 
P

pnp

Fixed the problem reading some different sites.

Made a vb macro with the following code:


-------- CODE BEGIN --------

sub sendQueryAsXML
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String

Subjectline = "eMail subject"
Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)

sXMLPath = CurrentProject.Path & "\AccessEXP.xml"

If Dir(sXMLPath) <> "" Then Kill sXMLPath
ExportXML acExportQuery, "QUERYNAME", sXMLPath

MyMail.Subject = Subjectline
MyMail.Attachments.Add(sXMLPath)

MyMail.Display = true

end sub

--------- CODE END ---------

Best regards
/Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top