473,385 Members | 1,890 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,385 software developers and data experts.

Logging an E-mail That has been sent via Access

171 100+
Hi I have been able to successfully send e-mails using MS Outlook via MS Access. However I can't seem to find any error logging techniques. What I want to do is create a log of any e-mails actually sent. I have no way of knowing whether an e-mail has or has not been sent, e.g. Line 34 in the below code will run regardless of whether the e-mail has been sent or not.


Thank You

P.S. Just for reference here's my code
Expand|Select|Wrap|Line Numbers
  1. Dim strEmail As String
  2. Dim strMsg As String
  3. Dim oLook As Object
  4. Dim oMail As Object
  5. Set oLook = CreateObject("Outlook.Application")
  6. Set oMail = oLook.CreateItem(0)
  7. With oMail
  8. .To = "iheartvba@vbassocool.com"
  9. .Subject = "HO Report From Office Number " & strOfficeID & " From " & (Me.cboStartDate + 1) & " To " & (Me.tbEndDate - 1)
  10. .Attachments.Add ("C:\HoXpt\qryXptTblChangeLogIMP.txt")
  11. .Attachments.Add ("C:\HoXpt\qryXptTblClientAddressesIMP.txt")
  12. .Attachments.Add ("C:\HoXpt\qryXptTblClientDetailsIMP.txt")
  13. .Attachments.Add ("C:\HoXpt\qryXptTblClientDetailsUPD.txt")
  14. .Attachments.Add ("C:\HoXpt\qryXptTblCollectionsIMP.txt")
  15. .Attachments.Add ("C:\HoXpt\qryXptTblCollectionsUPD.txt")
  16. .Attachments.Add ("C:\HoXpt\qryXptTblFFRBankDetailsIMP.txt")
  17. .Attachments.Add ("C:\HoXpt\qryXptTblFFRBkChangeLogIMP.txt")
  18. .Attachments.Add ("C:\HoXpt\qryXptTblFFRChangeLogIMP.txt")
  19. .Attachments.Add ("C:\HoXpt\qryXptTblFFRIMP.txt")
  20. .Attachments.Add ("C:\HoXpt\qryXptTblJobDetailsIMP.txt")
  21. .Attachments.Add ("C:\HoXpt\qryXptTblJobDetailsUPD.txt")
  22. .Attachments.Add ("C:\HoXpt\qryXptTblJobPeriodsChangeLogIMP.txt")
  23. .Attachments.Add ("C:\HoXpt\qryXptTblJobPeriodsIMP.txt")
  24. .Attachments.Add ("C:\HoXpt\qryXptTblPendingItemsIMP.txt")
  25. .Attachments.Add ("C:\HoXpt\qryXptTblPendingsChangeLogIMP.txt")
  26. .Attachments.Add ("C:\HoXpt\qryXptTblTimeCardIMP.txt")
  27. .Attachments.Add ("C:\HoXpt\qryXptTblVoidIMP.txt")
  28. .Attachments.Add ("C:\HoXpt\qryXptTblYearsPerReceiptChangeLogIMP.txt")
  29. .Attachments.Add ("C:\HoXpt\qryXptTblYearsPerReceiptIMP.txt")
  30. .Send
  31. End With
  32. Set oMail = Nothing
  33. Set oLook = Nothing
  34. DoCmd.OpenQuery "qryAppXptDt"
  35. MsgBox "Head Office Report Has Been Exported and E-mailed For The Period" & vbCrLf & (Me.cboStartDate + 1) & vbCrLf & "to" & vbCrLf & (Me.tbEndDate - 1)
  36. End Sub
  37.  
Nov 24 '08 #1
4 1900
PianoMan64
374 Expert 256MB
Hey iheartvba,

There are a few ways you can go about this:

1. You can simply create a table that when you issue the send command, that it will create a record in a table that indicates that a particular email was sent, based off of any information that you had in the objects of your email.

2. You can simply connect using ODBC to the sent folder of your local outlook client and verify that an email went out with a specific email address and so on.

It's really all up to how you want to track it, and where you want to check for errors.
Nov 24 '08 #2
PianoMan64
374 Expert 256MB
Hey iheartvba,

There are a few ways you can go about this:

1. You can simply create a table that when you issue the send command, that it will create a record in a table that indicates that a particular email was sent, based off of any information that you had in the objects of your email.

2. You can simply connect using ODBC to the sent folder of your local outlook client and verify that an email went out with a specific email address and so on.

It's really all up to how you want to track it, and where you want to check for errors.

Hope that helps,

Joe P.
Nov 24 '08 #3
iheartvba
171 100+
Thanks Joe.

I don't know how Solution 1 works so I went with Solution 2. I am encountering the follwoing error: Run-Time error '-2147217900 (80040e14)': Invalid SQL statement; expectde 'DELETE', 'INSERT', 'PROCEEDURE', 'SELECT' or 'UPDATE'.

My SQL string is as Follows

Expand|Select|Wrap|Line Numbers
  1. 'strSubject is the Subject of the e-mail
  2. 'olkSentItems is Outlook Sent Items table linked to Access
  3. 'Subject is the subject field in the linked outlook table 
  4. strSql = "SELECT Subject FROM olkSentItems WHERE Subject = '" & strSubject & "'"
  5. rst.Open "strSql", cnn, adOpenDynamic, adLockOptimistic
  6.  
Line 5 of the above code is where the error occurs

P.S. i don't know if this is relevant but, The objective of this code is to see if the record set is empty, if so then the user will be prompted to rerun the proceedure, otherwise the date of the sent e-mail will be logged in a table. I should not have too much of a problem with that once this SQL string starts working.

Thank You
Nov 24 '08 #4
iheartvba
171 100+
Hi,
Just learned that you can get the row count of a list box using the listCount function. So I have just created a list box with the query listed in Post #4 above and if the listCount function gives a value greater than zero it means the e-mail has been sent and therefore access can run a query to Log that fact!

yeah
Nov 27 '08 #5

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

Similar topics

1
by: jjesso | last post by:
I am trying to add a new logging level. logging.config.fileConfig("bengineLog.cfg") logging.CLIENT = logging.INFO + 1 logging.addLevelName( logging.CLIENT, 'CLIENT' ) logging.root.setLevel( )...
0
by: Karuppasamy | last post by:
H I am trying to use the Logging Module provided by Microsoft Application Blocks for .Net I installed everything as per the Instructions given in the 'Development Using the Logging Block' ...
6
by: pmatos | last post by:
Hi all, I am trying to create a simple but efficient C++ logging class. I know there are lots of them out there but I want something simple and efficient. The number one requirement is the...
23
by: Rotem | last post by:
Hi, while working on something in my current project I have made several improvements to the logging package in Python, two of them are worth mentioning: 1. addition of a logging record field...
6
by: Burkhard Schultheis | last post by:
As I wrote last week, we have a problem with a DB2 V8 on Linux. Here is what is in db2diag.log during online backup: Starting a full database backup. 2004-04-01-02.33.54.760164 ...
0
by: robert | last post by:
As more and more python packages are starting to use the bloomy (Java-ish) 'logging' module in a mood of responsibility and as I am not overly happy with the current "thickener" style of usage, I...
0
by: rajesh.hanchate | last post by:
Please help me in resolving this issue. I am using EnterpriseLibrary 2.0 Exception and logging block for logging exceptions to event log. It works fine for sometime. After some time it stops...
3
by: Chris Shenton | last post by:
I am setting up handlers to log DEBUG and above to a rotating file and ERROR and above to console. But if any of my code calls a logger (e.g., logging.error("foo")) before I setup my handlers, the...
3
by: Lowell Alleman | last post by:
Here is the situation: I wrote my own log handler class (derived from logging.Handler) and I want to be able to use it from a logging config file, that is, a config file loaded with the...
4
by: samwyse | last post by:
In the Python 2.5 Library Reference, section 14.5.3 (Logging to multiple destinations), an example is given of logging to both a file and the console. This is done by using logging.basicConfig()...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.