Results 1 to 4 of 4
  1. #1
    JJCHCK is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    30

    Send email with attachments not empty

    I'm new and i dont know how cancel my post (IsNull)

    nobody can help me

    I would send only email where reports have records



    I have many query and when they are empy I'd like to ignore

    how can I do?

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I think that you might have to write some VBA code to achieve what you are trying to do.

    It won't be too difficult - and you'll get plenty of help here.

    Are your reports based on Queries?

  3. #3
    JJCHCK is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    30
    I have query;this code work but i have 2 little problems:
    1) i want send 1 mail
    2) every query is attached so "qdf.pdf" but i'd like to get is real name


    Code:
    Private Sub Comando5_Click()
         On Error GoTo err:
    
     Dim VDb As DAO.Database
    Dim qdf   As QueryDef
    
    
     Const msg = “testo"
    
    Set VDb = CurrentDb
    
    
     Dim outApp As Outlook.Application, outMsg As MailItem
    
     Set outApp = CreateObject("Outlook.Application")
     Set outMsg = outApp.CreateItem(olMailItem)
    
    If VDb.QueryDefs.Count > 0 Then
    
     For Each qdf In CurrentDb.QueryDefs
    
        If qdf.Name = "Q_TipoDestinazDiv" Then
    
        Debug.Print qdf.Name
    
        Else
    
    If DCount("*", qdf.Name) > 0 Then
    
     DoCmd.OutputTo acQuery, qdf.Name, acFormatPDF, "C:\Documents and Settings\junior\Desktop\Controlli\" & qdf.Name
    
    
       With outMsg
          .Importance = olImportanceHigh
          .SendUsingAccount = outApp.Session.Accounts.Item(1)
    .ReadReceiptRequested = True ' conferma lettura
          .OriginatorDeliveryReportRequested = True ' conferma recapito
          .To = "xxx@tiscali.it"
          .CC = " yyy@tiscali.it "
          '.BCC = " ccc@tiscali.it "
          .Subject = "oggetto"
          .Body = msg
          .Attachments.Add ("C:\Documents and Settings\ junior \Desktop\Controlli\qdf.pdf")
          ‘.Display
          .Send
       End With
      End If
    End If
       Next qdf
    End If
    
       Set outApp = Nothing
       Set outMsg = Nothing
    
    err:
    If err > 0 Then
       MsgBox (err.Description & " " & err.Number)
    End If
    err.Clear
    
    End Sub

  4. #4
    JJCHCK is offline Advanced Beginner
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Posts
    30
    solved with Dcount(*,myquery)

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

Similar Threads

  1. Send a PDF via email.
    By tcheck in forum Access
    Replies: 3
    Last Post: 08-30-2011, 02:31 PM
  2. Send email with attachments
    By rbiggs in forum Programming
    Replies: 12
    Last Post: 07-23-2011, 12:50 PM
  3. Send Report and Attachments in Email
    By Pimped in forum Programming
    Replies: 1
    Last Post: 06-21-2011, 02:51 AM
  4. Replies: 4
    Last Post: 04-13-2011, 10:11 AM
  5. send email to email addresses in database?
    By cnstarz in forum Access
    Replies: 5
    Last Post: 03-02-2011, 09:46 PM

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