Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228

    Email PDF

    I have my databases creating invoices. I'm can get these to the right location on the server based on the company name and order number. But obviously I have to ensure these invoices are sent.

    Is it possible to create a PDF that only exists as an attachment in outlook? So if I clicked to send an invoice it would put it there and I don't need to worry about the one on our system. OR would I be better off writing the code that finds that PDF and then sends it from there?

    Hope that makes sense. I just need to do this from the database so I can track if anything's been sent and when. (not after any code yet just some advice).

    Thanks.

  2. #2
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    If I can get this code working I'll use this. I'm having a bit of trouble seeing what QDF does here.

    Code:
    Private Sub Command66_Click()
     
    Dim MyDb As DAO.Database
    Dim rsEmail As DAO.Recordset
    Dim qdf As DAO.QueryDef
    Dim prm As DAO.Parameter
    Dim strEmail As String
    Dim strMsg As String
    Dim oLook As Object
    Dim oMail As Object
    Set MyDb = CurrentDb
    Set qdf = MyDb.QueryDefs("qryexp_may11")
    For Each prm In qdf.Parameters
        prm.Value = Eval(prm.Name)
    Next
    Set rsEmail = qdf.OpenRecordset()
    Set oLook = CreateObject("Outlook.Application")
    With rsEmail
            .MoveFirst
            Do Until rsEmail.EOF
            myRecipient = .Fields(0)
                If IsNull(myRecipient) = False Then
                    Set oLook = CreateObject("Outlook.Application")
                    Set oMail = oLook.CreateItem(0)
                    With oMail
                        .To = myRecipient
                        .Body = "See attached"
                        .Subject = "Test Email"
                        .Attachments.Add ("\\mynetwork\mynetworkfolder\test.doc")
                        .Send
                    End With
                End If
                        .MoveNext
            Loop
    End With
    Set oMail = Nothing
    Set oLook = Nothing
    End Sub
    I think this is defining a list of emails and sending the attachment to everyone? If someone could confirm that.

  3. #3
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    Even better if someone can tell me how this line works:

    Code:
     myRecipient = .Fields(0)
    So the query I sbeing used as record set. I just don't see how .Fields(0). refers to that query.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    That refers to the first field in the recordset, which was opened on the query. Personally I prefer to use the field name.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    Join Date
    Jun 2015
    Location
    Wales. Land of the sheep.
    Posts
    1,228
    It makes more sense to me to refer to the field name too. Ill pick this up tomorrow I didn't get too far with it.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-23-2016, 01:28 PM
  2. Replies: 3
    Last Post: 12-28-2015, 04:11 PM
  3. Replies: 3
    Last Post: 05-18-2015, 11:24 AM
  4. Replies: 5
    Last Post: 05-07-2014, 09:25 AM
  5. Replies: 1
    Last Post: 05-01-2014, 11:37 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums