Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10

    Sending Multiple records via Outlook using HTML in Access

    Hello All,


    Please, i need an urgent assistance.

    I was trying to send some records via Outlook from Access to different customers, showing records like SupplierRef,Email,Amount,VAT, and a unique Payment Reference generated for each batch of payment. Let's say a batch with Payment Reference "FHN000001" contains 15 records for 3 suppliers 1,2 and 3 and each supplier has 5 records each. I want 5 records to be sent to each supplier in outlook mail, showing in a tabular form. As it is, each customer gets 5 different emails showing a line of transaction for each email. I want 3 emails to be sent, showing 5 lines of transaction per customer. I am sharing my codes below and screen shots.

    1. Query to select customer "qryEmail_NGN"

    [SELECT tbl_PayNGNArchieve.SupplierRef, tbl_PayNGNArchieve.InvoiceNo, tbl_PayNGNArchieve.InvoiceDate, tbl_PayNGNArchieve.Gross, tbl_PayNGNArchieve.VAT, tbl_PayNGNArchieve.WHT, tbl_PayNGNArchieve.LCD, tbl_PayNGNArchieve.Payment, tbl_PayNGNArchieve.Curr, tbl_PayNGNArchieve.DateReceived, tbl_PayNGNArchieve.Pay, tbl_PayNGNArchieve.Status, tbl_PayNGNArchieve.PaymentDate, tbl_PayNGNArchieve.PaymentRef FROM tbl_PayNGNArchieve GROUP BY tbl_PayNGNArchieve.SupplierRef, tbl_PayNGNArchieve.InvoiceNo, tbl_PayNGNArchieve.InvoiceDate, tbl_PayNGNArchieve.Gross, tbl_PayNGNArchieve.VAT, tbl_PayNGNArchieve.WHT, tbl_PayNGNArchieve.LCD, tbl_PayNGNArchieve.Payment, tbl_PayNGNArchieve.Curr, tbl_PayNGNArchieve.DateReceived, tbl_PayNGNArchieve.Pay, tbl_PayNGNArchieve.Status, tbl_PayNGNArchieve.PaymentDate, tbl_PayNGNArchieve.PaymentRef HAVING (((tbl_PayNGNArchieve.SupplierRef)=[forms]![PayNGN]![SupplierRef]) AND ((tbl_PayNGNArchieve.PaymentRef)=[forms]![SendNGN]![txt_PayRef])) ORDER BY tbl_PayNGNArchieve.SupplierRef;[/code]

    2. Code to send Email "Public Function SendEmail2

    [Function SendEmail2() 'Horizontal with border Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Set db = CurrentDb
    Set rs = db.OpenRecordset(" SELECT * FROM tbl_PayNGNArchieve WHERE PaymentRef='" & Forms![SendNGN]!txt_PayRef & "' ")
    Dim olApp As Outlook.Application
    Dim objMail As Outlook.MailItem
    Set olApp = Outlook.Application
    Dim Msg As String
    Dim Email As String
    Msg = DCount("SupplierRef", "tbl_PayNGNArchieve", "[PaymentRef]='" & Forms![SendNGN]!txt_PayRef & "' AND [Pay]='Yes' ")
    Email = DLookup("Email1", "tbl_PayNGNArchieve", "[PaymentRef]='" & Forms![SendNGN]!txt_PayRef & "' AND [SupplierRef]= '" & Form_PayNGN.txt_SupplierName & "'AND [Pay]='Yes' ")


    Do Until rs.EOF

    On Error Resume Next 'Keep going if there is an error
    Set objMail = olApp.CreateItem(olMailItem)
    With objMail

    .To = Email
    .subject = "Payment Advice -" & " " & rs!SupplierRef & ""
    .Importance = olImportanceHigh


    'Set body format to HTML
    .bodyFormat = olFormatHTML
    .bodyFormat = olFormatHTML


    .HTMLBody = "<font face=Calibri><h3>Dear " & rs!SupplierRef & ",</h3> " _
    & "Please be informed of the payment of " & rs!Curr & Format(Trim(rs!Payment), "#,##0.00;(#,##0.00)") & " made into your company’s bank account.<b> " _
    & "<p><b>Find below, breakdown of invoice(s) for which payment was made and please acknowledge receipt of funds upon confirmation.</b><br />" _




    .HTMLBody = .HTMLBody & " <html>"
    .HTMLBody = .HTMLBody & " <head>"
    .HTMLBody = .HTMLBody & " <style>"
    .HTMLBody = .HTMLBody & " table,th, td {"
    .HTMLBody = .HTMLBody & " border: 1px solid black;"
    .HTMLBody = .HTMLBody & " border-collapse: collapse;"
    .HTMLBody = .HTMLBody & "}"
    .HTMLBody = .HTMLBody & " table,th, td {"
    .HTMLBody = .HTMLBody & "padding: 5px;"
    .HTMLBody = .HTMLBody & "}"
    .HTMLBody = .HTMLBody & "th {"
    .HTMLBody = .HTMLBody & "text-align: left;"
    .HTMLBody = .HTMLBody & "}"
    .HTMLBody = .HTMLBody & " </style>"
    .HTMLBody = .HTMLBody & " </head>"
    .HTMLBody = .HTMLBody & " <body>"
    .HTMLBody = .HTMLBody & "<table>"
    .HTMLBody = .HTMLBody & " <tr>"
    .HTMLBody = .HTMLBody & " <th>Payment Reference</th>"
    .HTMLBody = .HTMLBody & " <th>Invoice Number</th>"
    .HTMLBody = .HTMLBody & " <th>Invoice Date</th>"
    .HTMLBody = .HTMLBody & " <th>Gross Amountz</th>"
    .HTMLBody = .HTMLBody & " <th>VAT</th>"
    .HTMLBody = .HTMLBody & " <th>WHT</th>"
    .HTMLBody = .HTMLBody & " <th>LCD</th>"
    .HTMLBody = .HTMLBody & " <th>Net Amount</th>"
    .HTMLBody = .HTMLBody & " <th>Currency Code</th>"
    .HTMLBody = .HTMLBody & " </tr>"
    .HTMLBody = .HTMLBody & " <tr>"
    .HTMLBody = .HTMLBody & "<td>" & rs!PaymentRef & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & rs!InvoiceNo & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & rs!InvoiceDate & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & Format(Trim(rs!Gross), "#,##0.00;(#,##0.00)") & " </td>"
    .HTMLBody = .HTMLBody & "<td>" & Format(Trim(rs!VAT), "#,##0.00;(#,##0.00)") & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & Format(Trim(rs!WHT), "#,##0.00;(#,##0.00)") & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & Format(Trim(rs!LCD), "#,##0.00;(#,##0.00)") & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & Format(Trim(rs!Payment), "#,##0.00;(#,##0.00)") & "</td>"
    .HTMLBody = .HTMLBody & "<td>" & rs!Curr & "</td>"
    .HTMLBody = .HTMLBody & " </tr>"
    '.HTMLBody = .HTMLBody & " <th>Total</th>"
    '.HTMLBody = .HTMLBody & "<td>" & Format(Trim(Total), "#,##0.00;(#,##0.00)") & "</td>"
    '.HTMLBody = .HTMLBody & "<td>" & Format(Trim(rs!Payment), "#,##0.00;(#,##0.00)") & " </td>"
    .HTMLBody = .HTMLBody & " </table>"
    .HTMLBody = .HTMLBody & "<br><br>Regards "
    .HTMLBody = .HTMLBody & "<br>Olajumoke Nwabuisi."
    .HTMLBody = .HTMLBody & "</body></html>"

    .display
    '.Send

    rs.MoveNext
    End With
    Loop

    rs.Close
    Set rs = Nothing
    Set db = Nothing

    MsgBox (Msg & " " & "Mails successfully sent"), vbInformation, Title

    End Function [/code]

    I also want to be able to attach a pdf. file for each customer showing payments made.

    Will appreciate you kind/urgent assistance.

    Thank you all.
    Attached Files Attached Files
    Last edited by oladapo; 08-28-2017 at 03:02 AM. Reason: To add database copy

  2. #2
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    Hello All,

    Please, I have attached a database copy for your assistance. (It's version 2013, 64 bit) and an excel upload file "NGN"

    Thank you
    Attached Files Attached Files

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Here's my favorite email link: http://www.granite.ab.ca/access/email.htm

    You may have some trouble with the db you posted as I believe most who help here use 32 bit MS Access.

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    You haven't said what the problem is. I/we can't decipher enough from your code to be specific since we have no idea what the record set(s) look like, and as noted, the db version will be a problem for some/most who are active here. I'm not even going to attempt to open it for that reason. So I'm going to generalize and say that I think you need nested loops with a variable for the recipient. The outer loop sets a variable to recipient A, the inner loop concatenates the records/text into the email for recipient A. When the inner loop goes back to the top to perform each concatenation, it checks if the recipient for that record matches the variable. If not, you exit the inner loop, which means execution goes to the outer loop and you MoveNext to get the next recipient and reset the variable. Execution then goes back to the inner loop and concatenates the next set of records/text. The trick is getting the loops and record moves (MoveNext or whatever). I have found the best way is to scratch general code steps onto a writing pad with pencil and figure out the logic before attempting code.

    P.S. lengthy code belong in code tags - it's appreciated.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    RuralGuy,

    Thank you for your response, I appreciate. Will check out the link you provided as well.

  6. #6
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    Hello Micron,

    I stated the problem in my first post, i guessed you started off with the addendum post that i made, nevertheless, i appreciate your feedback. I am new to this platform, joined whilst seeking solution to the issue at hand and wasn't aware it was a 32 bit community, my apologies.

    I kind of understand the logic you presented but my vba skills ain't strong to code that. Its good to do things yourself but there are somethings you don't struggle with and that explains why i am here to learn, so i can become a better person. I do hope someone can help, i have quoted the issue below again.

    "Hello All,

    Please, i need an urgent assistance.

    I was trying to send some records via Outlook from Access to different customers, showing records like SupplierRef,Email,Amount,VAT, and a unique Payment Reference generated for each batch of payment. Let's say a batch with Payment Reference "FHN000001" contains 15 records for 3 suppliers 1,2 and 3 and each supplier has 5 records each. I want 5 records to be sent to each supplier in outlook mail, showing in a tabular form. As it is, each customer gets 5 different emails showing a line of transaction for each email. I want 3 emails to be sent, showing 5 lines of transaction per customer. I am sharing my codes below and screen shots."

  7. #7
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    You latest post doesn't add anything to my lack of understanding:
    I/we can't decipher enough from your code to be specific since we have no idea what the record set(s) look like,
    Your screen shots didn't come through.
    The solution may require complex code, or it might be a simpler query solution (usually involving sub queries, which I struggle with immensely). If you want to provide the following, I will take a deeper look: go to Excel, create some data that resembles the query output (or paste some query output), centre the field headings and data, copy & paste into a thread reply. Do this also for how the emails should be grouped. Make sure the desired result is evident. I will copy/paste into test table(s) and see how/if I can produce the output. Note: I'm not going to type out all these records, so don't paste a picture of the data. I need the correct names of the query and fields that make up your records for the data being emailed. I do not want to use pseudo names and have you tell me later that you can't edit it. I don't mean to be terse, but if I'm going to devote time to this, you have to make it as easy as you can.

    OK, I left all the above in seeing as how it took so long. Then I decided to check if you might have cross posted this, and I see that you have:
    http://www.utteraccess.com/forum/ind...&#entry2656569
    Please read this https://www.excelguru.ca/content.php?184

    I usually bow out when someone has 2 groups of people working on the same thing and no one knows.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  8. #8
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    Hello Micron,

    Thank you for your response. Sincere apologies if i got anyone angry about my request. I am a first timer and i needed assistance and did "cross-posted" as you found out but will sure stick in here going forward. Please see sample data below as requested: Table below is my initial data that is uploaded from excel into tbl_PayNGNArchieve

    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef Email1 Email2 Email3 Copy1 Copy2
    21st Century Technologies AS/14398 FHN/Apr 17 04-May-17 789127.5 789127.5 NGN 10-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 21st Century@gmail.com
    Best Western (Homeville Hotel) 4/28/2017 28-Apr-17 287100 287100 NGN 10-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Best Western@gmail.com
    Business Intelligence & Data Services Ltd 01042017 13-Apr-17 315000 15000 15000 3000 282000 NGN 16-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Business Intell@gmail.com
    Cardinal Security Services Limited CSSL/17/417 28-Feb-17 1141350 54350 54350 10870 1021780 NGN 24-Mar-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Cardinal Securi@gmail.com
    Cardinal Security Services Limited CSL/17/638 31-Mar-17 1026375 48875 48875 9775 918850 NGN 21-Apr-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Cardinal Securi@gmail.com
    Cardinal Security Services Limited CSL/17/720 02-May-17 101640 840 840 168 99792 NGN 23-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Cardinal Securi@gmail.com
    Emerging Market Telecommunication Services January 2017 Bill 25-Apr-17 588567.71 588567.71 NGN 25-Apr-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Emerging Market@gmail.com
    Emerging Market Telecommunication Services February 2017 Bill 25-Apr-17 542360.07 542360.07 NGN 25-Apr-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005 Emerging Market@gmail.com


    Code for tbl_PayNGNArchieve below

    Code:
    SELECT tbl_PayNGNArchieve.SupplierRef, tbl_PayNGNArchieve.InvoiceNo, tbl_PayNGNArchieve.InvoiceDate, tbl_PayNGNArchieve.Gross, tbl_PayNGNArchieve.VAT, tbl_PayNGNArchieve.WHT, tbl_PayNGNArchieve.LCD, tbl_PayNGNArchieve.Payment, tbl_PayNGNArchieve.Curr, tbl_PayNGNArchieve.DateReceived, tbl_PayNGNArchieve.Email1, tbl_PayNGNArchieve.Email2, tbl_PayNGNArchieve.Email3, tbl_PayNGNArchieve.Copy1, tbl_PayNGNArchieve.Copy2, tbl_PayNGNArchieve.Pay, tbl_PayNGNArchieve.Status, tbl_PayNGNArchieve.PaymentDate, tbl_PayNGNArchieve.PaymentRef FROM tbl_PayNGNArchieve;
    Below is the desired result; data to be sent as email body to each customer at a single click.

    21st Century@gmail.com
    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef
    21st Century Technologies AS/14398 FHN/Apr 17 04-May-17 789127.5 789127.5 NGN 10-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Best Western@gmail.com
    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef
    Best Western (Homeville Hotel) 4/28/2017 28-Apr-17 287100 287100 NGN 10-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Business Intell@gmail.com
    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef
    Business Intelligence & Data Services Ltd 01042017 13-Apr-17 315000 15000 15000 3000 282000 NGN 16-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Cardinal Securi@gmail.com
    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef
    Cardinal Security Services Limited CSSL/17/417 28-Feb-17 1141350 54350 54350 10870 1021780 NGN 24-Mar-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Cardinal Security Services Limited CSL/17/638 31-Mar-17 1026375 48875 48875 9775 918850 NGN 21-Apr-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Cardinal Security Services Limited CSL/17/720 02-May-17 101640 840 840 168 99792 NGN 23-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Emerging Market@gmail.com
    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef
    Emerging Market Telecommunication Services January 2017 Bill 25-Apr-17 588567.71 588567.71 NGN 25-Apr-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005
    Emerging Market Telecommunication Services February 2017 Bill 25-Apr-17 542360.07 542360.07 NGN 25-Apr-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005



    I also want this to be attached to each mail sent out in pdf format.

    Please let me know if you would need more information. Thank you for your assistance.

  9. #9
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Cross posting is considered acceptable if you include a link to all other forums where you've posted a question.
    As for your most recent posts, would sending a copy of an Access report to each recipient with only their record(s) be an option? Or a pdf or other version of your output query?

  10. #10
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    Thank you Micron,

    Sending a .pdf copy to each recipient with only their record(s) would be fine, at the click of a button.

    Again, thank you.

  11. #11
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Have re-read from the beginning and I'm confused about this
    I want 5 records to be sent to each supplier in outlook
    versus this
    I also want this to be attached to each mail sent out in pdf format.
    I'm half way through an html construct to build a table for an email using the info you provided. At first, I figured it would be too much to tackle but maybe not. I intend to test it with the sample data you provided in post#8, so if that's not how the query output looks (for the sql you posted) please let me know ASAP.

  12. #12
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    Thank you Micron, i appreciate your effort.

    Kindly work with post #8. The request was to have both html table for an email and a copy of same data sent as attachment to each recipient (within same mail with only their records), for example, record below is sent to Century@gmail.com as html mail body and pdf attachment in same mail, but would prefer html email body if only one can be achieved.

    21st Century@gmail.com
    SupplierRef InvoiceNo InvoiceDate Gross VAT WHT LCD Payment Curr DateReceived Pay Status PaymentDate PaymentRef
    21st Century Technologies AS/14398 FHN/Apr 17 04-May-17 789127.5 789127.5 NGN 10-May-17 Yes Paid 8/25/2017 8:23:18 AM FHN00000005

  13. #13
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Are you sending email to supplier or customer? You use both nouns in your OP.

    Need two loops. One approach can use two recordsets - one recordset for the SupplierRef and email and another recordset for the payments info. The outer loop reads the suppliers recordset and the inner loop reads the payments recordset. A one recordset approach would require using a variable to hold the SupplierRef. Manage the looping by comparing variable to the value in record as code loops through the recordset. When the SupplierRef changes, exit inner loop, send email, reset the variable, repeat outer loop.

    If you want to also attach the report as a PDF, options:

    1. open report, use SendObject command to send email, close report

    2. open report, use OutputTo command to save report to external PDF file, attach to Outlook object, close report

    Consider two recordset approach:
    Code:
    Set rsSupp = db.OpenRecordset("SELECT DISTINCT SupplierRef, Email1 FROM tbl_PayNGNArchieve WHERE PaymentRef='" & Forms![SendNGN]!txt_PayRef & "'";")
    Do Until rsSupp.EOF
        On Error Resume Next 'Keep going if there is an error
        Set objMail = olApp.CreateItem(olMailItem)
        With objMail
        .To = rsSupp!Email
        .Subject = "Payment Advice - " & rs!SupplierRef
        .Importance = olImportanceHigh
        'Set body format to HTML
        .BodyFormat = olFormatHTML
        Set rs = db.OpenRecordset("SELECT * FROM tbl_PayNGNArchieve WHERE SupplierRef = " & rsSupp!SupplierRef & " AND PaymentRef='" & Forms![SendNGN]!txt_PayRef & "'")
        Do Until rs.EOF
            .HTMLBody = .HTMLBody & "<tr>" _
                & "<td>" & rs!PaymentRef & "</td>" _
                & "<td>" & rs!InvoiceNo & "</td>" _
                & "<td>" & rs!InvoiceDate & "</td>" _
                & "<td>" & Format(Trim(rs!Gross), "#,##0.00;(#,##0.00)") & "</td>" _
                & "<td>" & Format(Trim(rs!VAT), "#,##0.00;(#,##0.00)") & "</td>" _
                & "<td>" & Format(Trim(rs!WHT), "#,##0.00;(#,##0.00)") & "</td>" _
                & "<td>" & Format(Trim(rs!LCD), "#,##0.00;(#,##0.00)") & "</td>" _
                & "<td>" & Format(Trim(rs!Payment), "#,##0.00;(#,##0.00)") & "</td>" _
                & "<td>" & rs!Curr & "</td>" _
                & "</tr>"
            rs.MoveNext
        Loop
        .HTMLBody = "<font face=Calibri><h3>Dear " & rsSupp!SupplierRef & ",</h3> " _
            & "Please be informed of the payment of " & rs!Curr & Format(Trim(rs!Payment), "#,##0.00;(#,##0.00)") & " made into your company’s bank account.<b> " _
            & "<p><b>Find below, breakdown of invoice(s) for which payment was made and please acknowledge receipt of funds upon confirmation.</b><br />" _
            & "<html><head><style>" _
            & "table,th,td{border: 1px solid black; border-collapse: collapse;}table,th,td{padding: 5px;}th{text-align: left;}</style></head>" _
            & "<body><table>" _
            & "<tr><th>Payment Reference</th>" _
            & "<th>Invoice Number</th>" _
            & "<th>Invoice Date</th>" _
            & "<th>Gross Amountz</th>" _
            & "<th>VAT</th>" _
            & "<th>WHT</th>" _
            & "<th>LCD</th>" _
            & "<th>Net Amount</th>" _
            & "<th>Currency Code</th></tr>" _
            & .HTMLBody _
            & "<th>Total</th>" _
            & "<td>" & Format(Trim(Total), "#,##0.00;(#,##0.00)") & "</td>" _
            & "<td>" & Format(Trim(rs!Payment), "#,##0.00;(#,##0.00)") & " </td>" _
            & "</table>" _
            & "<br><br>Regards " _
            & "<br>Olajumoke Nwabuisi." _
            & "</body></html>"
        rs.Close
        DoCmd.OpenReport "reportname", acViewPreview, , "SuppID = " & rsSupp!SuppID & " AND PaymentRef='" & Forms![SendNGN]!txt_PayRef & "'"
        DoCmd.OutputTo acOutputReport, "reportname", acFormatPDF, "path\payments.pdf"
        DoCmd.Close acReport, "reportname"
        .Attachment.Add ("path\payments.pdf")
        .Display
        End With
        rsSupp.MoveNext
    Loop
    rsSupp.Close
    Last edited by June7; 09-04-2017 at 12:38 PM.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  14. #14
    oladapo is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2017
    Posts
    10
    Thank you June7,

    I sighted the "Distinct" in your code and it opened my eyes to something i had overlooked and many other discoveries. I will parse the code and let you know whilst i also wait for Micron's feedback.

    Thank you all.

  15. #15
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,791
    Thanks June. I said that in my post #4 but somehow ended up in a different place, so to speak. Thought I had posted what I had up to that point, but don't see it here. Maybe I posted it to the wrong thread. There was a function call to append each row to a table for a specific recipient...

    oladapo: if the code works, I'd go with it. In the meantime, I'll see if I can figure out what the heck I did (or didn't do).

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 08-12-2015, 12:52 PM
  2. Sending Outlook Emails from form in Access 2007
    By IncidentalProgrammer in forum Programming
    Replies: 4
    Last Post: 01-09-2015, 11:06 AM
  3. Sending Emails from Access via Outlook
    By Terry Lawson in forum Programming
    Replies: 3
    Last Post: 11-14-2014, 10:03 AM
  4. Sending HTML files via Access to Outlook
    By Yann63 in forum Programming
    Replies: 4
    Last Post: 02-13-2014, 05:34 PM
  5. Access 97 Sending a Report to Outlook with Problems
    By PianistChris in forum Access
    Replies: 3
    Last Post: 07-18-2013, 12:17 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