473,378 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Multiple Reports attached to an email

135 100+
So, I have a database I'm using for Employee Time Sheets. The pay period is a two week cycle. There is one report for each week. I would like to just combine the two weeks into one report, but my company has this "interesting" (say backwards) system that they don't want to change. So instead of filling out the time sheets by hand *gasp* (I know) I created a database (obviously). Anyway, how can I attach both reports to a single email? I have a button for emailing that will send both reports to my email, but each report creates its own message and attaches itself. Don't really want to send two emails for each employee. Thanks for your always mind blowing help.
Nov 16 '08 #1
5 2401
MyWaterloo
135 100+
Sorry. I am using office 2007. So outlook is my email app. Thanks
Nov 16 '08 #2
MyWaterloo
135 100+
Just moving the thread back to the top hoping for an answer.
Nov 16 '08 #3
nico5038
3,080 Expert 2GB
For this you'll need to save the reports as a file and create an email with multiple attachments.

I assume you can create the needed files, here (part of) the Microsoft sample code for creating outlook emails with attachments.
Expand|Select|Wrap|Line Numbers
  1. Sub CallCreateMail()
  2.     ' This procedure shows how to pass an array of recipients,
  3.     ' a subject line, a message body, and an array of attachments
  4.     ' to the CreateMail procedure.
  5.     Dim strSubject      As String
  6.     Dim strBody         As String
  7.     Dim avarRecip(2)    As Variant
  8.     Dim avarAttach(2)   As Variant
  9.  
  10.     ' Create recipients array.
  11.     avarRecip(0) = "Maria Anders"
  12.     avarRecip(1) = "Ana Trujillo"
  13.     avarRecip(2) = "Antonio Moreno"
  14.  
  15.     ' Create attachments array.
  16.     avarAttach(0) = "c:\bootlog.txt"
  17.     avarAttach(1) = "c:\autoexec.bat"
  18.     avarAttach(2) = "c:\config.sys"
  19.  
  20.     ' Create Subject line and message body.
  21.     strSubject = "This is the subject line."
  22.     strBody = "If not now, when? If not you, who?"
  23.  
  24.     If CreateMail(avarRecip, strSubject, strBody, avarAttach) = True Then
  25.         MsgBox "Congratulations! Your mail has been sent."
  26.     End If
  27.  
  28. Function CreateMail(astrRecip As Variant, _
  29.                     strSubject As String, _
  30.                     strMessage As String, _
  31.                     Optional astrAttachments As Variant) As Boolean
  32.     ' This procedure illustrates how to create a new mail message
  33.     ' and use the information passed as arguments to set message
  34.     ' properties for the subject, text (Body property), attachments,
  35.     ' and recipients.
  36.  
  37.     Dim objNewMail          As Outlook.MailItem
  38.     Dim varRecip            As Variant
  39.     Dim varAttach           As Variant
  40.     Dim blnResolveSuccess   As Boolean
  41.  
  42.     On Error GoTo CreateMail_Err
  43.  
  44.     ' Use the InitializeOutlook procedure to initialize global
  45.     ' Application and NameSpace object variables, if necessary.
  46.     If golApp Is Nothing Then
  47.         If InitializeOutlook = False Then
  48.             MsgBox "Unable to initialize Outlook Application " _
  49.                 & "or NameSpace object variables!"
  50.             Exit Function
  51.         End If
  52.     End If
  53.  
  54.     Set golApp = New Outlook.Application
  55.     Set objNewMail = golApp.CreateItem(olMailItem)
  56.     With objNewMail
  57.         For Each varRecip In astrRecip
  58.             .Recipients.Add varRecip
  59.         Next varRecip
  60.         blnResolveSuccess = .Recipients.ResolveAll
  61.         For Each varAttach In astrAttachments
  62.             .Attachments.Add varAttach
  63.         Next varAttach
  64.         .Subject = strSubject
  65.         .Body = strMessage
  66.         If blnResolveSuccess Then
  67.             .Send
  68.         Else
  69.             MsgBox "Unable to resolve all recipients. Please check " _
  70.                 & "the names."
  71.             .Display
  72.         End If
  73.     End With
  74.  
  75.     CreateMail = True
  76.  
  77. CreateMail_End:
  78.     Exit Function
  79. CreateMail_Err:
  80.     CreateMail = False
  81.     Resume CreateMail_End
  82. End Function
  83.  
More code can be found at the Microsoft site.

Nic;o)
Nov 16 '08 #4
MyWaterloo
135 100+
Thanks Nico,
I guess I was just hoping there might be some easier way before I dive into manipulating Outlook (I have yet to sail those waters). But...I guess not. Thanks again.
Nov 16 '08 #5
nico5038
3,080 Expert 2GB
Hmm, you might try to create one report with both weekly reports as sub reports, but that will probably give some page layout problems. The combined report can be mailed "straight away"

Nic;o)
Nov 16 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Gary Wright | last post by:
I have a fairly large application in which the users seem to frequently want their reports changed - even if it is just the layout. What is the best way to allow users to create their own reports,...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
7
by: Mega1 | last post by:
is this possable to send more than 1 report in one email
2
by: Barry Edmund Wright | last post by:
Hi, I have two reports that I want to attach to the same email: rptBugReport rptBugLog I can sent the one using: DoCmd.SendObject acOutputReport, "rptBugReport", acFormatSNP How can I add...
3
by: Brian Farnhill (MCP VB.NET) | last post by:
Hi, I am having some trouble using the MailMessage object to send an email with more than one attachment. I am working on a web based application where a user can submit information, along...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
16
by: JoeW | last post by:
I'm utilizing a database that I created within MS Access within a program I've created in VB.NET. I am using the VB front end to navigate the information, but want to be able to print a report,...
7
by: google | last post by:
I am trying to automate the way reports are printed in an Access 2003 database - I have ~200 records (people) who require between 5 and 10 customized reports (depending on values within certain...
22
by: g diddy | last post by:
Hi I'm relatively new to VBA and could really do with some help please!! This is going to sound really long winded i'm sorry but I hope it will paint a picture of what i'm trying to do. Basically...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.