Export query to xml and mail that.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
Back
Top