<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F&amp;blogLocale=en_US&amp;homepageUrl=http%3A%2F%2Fwww.msaccesstips.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>
www.msaccesstips.com

LEARN MS-ACCESS TIPS AND TRICKS


International Response Fund

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Friday, November 16, 2007

Automated Email Alerts

Continued from previous Post: Configure Outlook for Lotus Notes.

The next procedure, that we are going to look into, is applicable for both Internet as well as Intranet Emails. We have already configured Microsoft Outlook with Lotus Notes Profile for those who would like to try sending scheduled Emails from MS-Access in their Local Area Network (LAN).


When we invoke the SendObject Action to send Emails with applicable parameters, the Target Addresses will be picked up from the default MS-Outlook Profile (Internet or Lotus Notes) and transmit Emails to destination.


We will send the Mail Alerts on a weekly schedule and little more preparation is required for this event. We need two small tables for the Program.


  1. A Local Address Book Table to keep the Recipient’s Addresses in Access.


  2. NB: It is possible to attach MS-Outlook Address Book or Lotus Notes Address Book to Microsoft Access Database.


    We may be having Email addresses of many individuals in our Contact List in MS-Outlook or Lotus Notes. But, we are planning to send the automated Mail Alerts regularly only to few people who are involved with the subject matter. We will keep a list of those email addresses picked from the Address Book of the configured profile (please see the fifth image in the earlier Post: Configure Outlook for Lotus Notes) in a local table. Sample image of the local Address Table for Lotus Notes Mail is given below:


    Address Table Image

    We can read the contents of this Table with Code and create the To… & Cc… Field values of the Email message.


    Lotus Notes Email Addresses are very lengthy with Location Names, Department Names and other details separated with forward slash, like


    Nancy Davollio/Ohio/hrd/Orgzn01@Orgzn01.


    In our local address table we only need to keep the First-Name, Last-Name part (Nancy Davolio) to use as Mail ID. When the Mail is send through Lotus Notes it will find and pick the full Email Addresses using the First Name, Last Name part from its main Address Book and insert them into the Mail.


    Suppose the contents of the Mail attachment (the Report), should go to only certain recipients in our address book on a particular day and we don’t want others to receive the Mail. To implement such type of refinement in the mail sending procedure we must find a way to filter out unwanted Addresses for the current mail. This can be achieved if some kind of personal identification information (like the employee Code), were already recorded in the main table. The employee code also must be included in the Address Book Table in a separate field (See the ECODE field in the above Address Book image). Having this information in both files we can easily link them together and pick addresses that match with the Report Source Data. Or in Program we can search for the employee code in the address table using the Report Source data Value and pick the email addresses. This way we can ensure that the mails with report attachment goes to the correct recipients and prevented others from getting the mail. But, here we will try the simple method.


  3. Second one is a control parameter table for the Email Program, which holds the weekly mail alert schedule information. The Parameter Table image is given below:


Email Schedule Parameter Table

Your Application may be shared by several users but it is not necessary to configure all the PCs for sending emails. Even if they all are, we don’t want our mails to go from different machines. When the Application is open in any of those machines the program will perform a check to identify the correct machine to send the mail. For this we will keep the Computer Name in a field to cross-check with the active Machine Name.


You can look for your computer’s name in one of two methods explained below.


  1. Right-Click the My Computer Desktop Icon and click on the Properties option in the displayed menu. Select the Computer Name Tab. Your Computer’s name will appear at the right side of the Full computer name: label.


  2. Click on Start Menu; select Run… then type cmd in the Open control and click OK. The DOS command prompt will appear. Type Set and press Enter Key. This action will display a lengthy list of Environment Variable settings. Among them you will find your computer’s name like COMPUTERNAME=X where X stands for your Computer's name.


We can check for this value using VB Function Environ() with the parameter value COMPUTERNAME.


X = Environ(“COMPUTERNAME”)

Our Mail is scheduled to send only once in a week on a particular day, let us say every Monday. We assume that the Application will be opened for normal use every day by the User(s) and every time the Program will perform a check for the mail sending schedule. If it is Monday then the mail must go out only once on that day with the Report attachment, even if the Application is open several times on Monday.


It can also happen that the user forgot to open the Application exactly on Monday or it was a holiday and the Mail schedule is by passed. In such cases whenever the user opens the Application next time, any Day, the overdue mail should go and must get prepared itself for the next mail sending schedule on next Monday. For this preparation we will keep a date in the parameter table. Let us start with the sample date Monday, November 19, 2007.


With the above lines I hope our preparation story is all done and it is time to go for the VB Code. Copy the Main Program given below and paste it into a Global Module of your Project and save the Module.



Public Function SendWeeklyMail()
'--------------------------------------------------------
'Author : a.p.r. pillai
'Date : 01/11/2007
'--------------------------------------------------------
Dim db As Database, rst As Recordset
Dim m_Addto As String, m_Cc As String, j As Integer
Dim msgBodyText As String, m_Subject As String
Dim m_MailDate, m_ComputerName As String, chk_CName As String

On Error GoTo SendWeeklyMail_Err

'Field Name and Table Name are same
m_MailDate = DLookup("MailDate", "MailDate")
m_ComputerName = DLookup("ComputerName", "MailDate")
chk_CName = Environ("COMPUTERNAME")

'identify the Mail Client Computer
If chk_CName <> m_ComputerName Then
Exit Function
End If

'Verify Mail Schedule
If m_MailDate + 7 > Date Then
Exit Function ' mail not due
End If

m_Addto = ""
m_Cc = ""
j = 0

'Create Address List
Set db = CurrentDb
Set rst = db.OpenRecordset("Add_Book", dbOpenDynaset)
Do While Not (rst.EOF)
If rst!TO Then
If Len(m_Addto) = 0 Then
m_Addto = rst![MailID]
Else
m_Addto = m_Addto & ", " & rst![MailID]
End If

ElseIf rst![cc] Then

If Len(m_Cc) = 0 Then
m_Cc = rst![MailID]
Else
m_Cc = m_Cc & ", " & rst![MailID]
End If

End If
rst.MoveNext
Loop
rst.Close

m_Subject = "BANK GUARANTEE RENEWAL REMINDER"

msgBodyText = "Bank Guarantee Renewals Due weekly Status Report as on " _
& Format(Date, "dddd, mmm dd,yyyy") _
& " which expires within next 15 days Cases is attached for review and " _
& "necessary action. "
msgBodyText = msgBodyText & vbCr & vbCr & "Machine generated email, " _
& " please do not send reply to this email." & vbCr

'replace x with your Lotus Notes password retaining the ~ character at end.
SendKeys "xxxxxxx~", False

DoCmd.SendObject acReport, "BG_Status", "SnapshotFormat(*.snp)", _
m_Addto, m_Cc, "", m_Subject, msgBodyText, False, ""

'Update MailDate to current date (if Monday) or date of
'previous Monday, if the mail was send after the due date.

Set rst = db.OpenRecordset("MailDate", dbOpenDynaset)
rst.Edit
Do While rst![MailDate] + 7 <= Date
rst![MailDate] = rst![MailDate] + 7
Loop
rst.Update
rst.Close

SendWeeklyMail_Exit:
Exit Function

SendWeeklyMail_Err:
MsgBox Err.Description, , "SendWeeklyMail()"
Resume SendWeeklyMail_Exit

End Function


In the above Code you must make a change in the SendKeys “xxxxxxx~”, False command parameter given in quotes. You must replace the x characters with your Lotus Notes Password and retain the tilde (~) character, which is equal to the Enter Key stroke.


This will send the Lotus Notes password in advance and expected to meet the Password Prompt of Lotus Notes in time, in that case the password Prompt will not pop up. Since, the mail is routed through different channels this is a blind-folded shot and can miss the target, in that case Lotus Notes will demand for the password and you have no other choice but to key in manually and press Enter.


For Internet Users this can be disabled with a single quote at the left side of the command, if the SMTP in Outlook is already configured with the Email password.


We will put few lines of code on the Control Screen Module to give a few seconds delay immediately after opening the Application to get set for calling the SendWeeklyMail() Program.


‘ put the next line at the header section of the Module
Dim i as integer

Private Sub Form_Load()
i = 0
Me.TimerInterval = 1000
End Sub


Private Sub Form_Timer()
i=i+1
If i = 16 then ‘ 15 seconds delay
Me.Timerinterval = 0
SendWeeklyMail
End if
End Sub


Copy and paste the above lines in the Control Screen Module save and close the Form. Try out the Automated pre-scheduled EMail Procedure.



MS-Access & Graph Charts-2
MS-Access & Graph Charts
Reports Page Border
Highlighting Reports
Saving Data on Forms Not in Table

Labels:

0 Comments:

Post a Comment

Note:Comments subject to Review by Blog Author before displaying.

Links to this post:

Create a Link

<< Home


Creative Commons License
Learn MS-Access Tips and Tricks by msaccesstips.com is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.



This Page is best viewed with 1280 x 1024 Resolution

   FEATURED LINKS
SITEMAP
Command Button Animation
3D Headings on Forms
MsgBox & Office Assistant
Reminder Ticker
MS-Access & E-Mails
Automated E-Mail Alerts
MsgBox with Options Menu
Colorful Command Buttons
Configure Lotus Notes
Alerts through Network
Running this site has become a costly affair as the revenue from Ads is not sufficient to support it. If you find these pages informative & useful and would like to extend a helping hand, then please do it here.





Link Back to us with this Button

Learn MS-Access

Copy and Paste this HTML Code in your Webpage


Add to Technorati Favorites

Programming Blogs - Blog Catalog Blog Directory
Powered by FeedBurner
Add to Google

Software
Computers blogs
TopOfBlogs




AddMe - Search Engine Optimization Submit Your Site Free!
Go BlogZ Ave Blogs
eBlogzilla Changing LINKS
LS Blogs Blogarama
blog search directory BlogUniverse
Find Blogs in Directory RSS Directory
blogskinny.com ShowcaseBlogs.com
Amfibi

Search Engine Optimization and SEO Tools
Dmegs Web Directory Takeaway for Sale Businesses For Sale
Free Submission Directory Free site submission

Free Listing
 





Free Page Rank Checker

AddThis Social Bookmark Button

Enter your email address:

Delivered by FeedBurner



Top Blogs


Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.

My Photo
Name: Ramachandran Pillai
Location: Cochin, India

I am not an Access Guru and not through MS-Access yet. More to learn and I don’t think that aspect has any end because others have their own style of using this tool. We can learn lot more tricks, other than what we already know, from others too. My programming skills in COBOL, BASIC, Turbo-C, dBase, FoxPro, Visual Basic & Basic HTML attained through self-learning. I wrote my first COBOL Program in 1975 for ICL1901, 3rd Generation Main Frame Computer. Worked as a Computer Operator (NCR VRX8555 Mainframe Machine upto 1990) with M/s. Y.B.A. Kanoo, Saudi Arabia. Started using MS-Access Ver.2 in 1996, when dBase III+ and Foxbase (later version Foxpro) were my favorite DBMS. During Last 13 Year period I have developed more than 45 In-House Applications (medium & small) under MS-Access for our Organization, a leading Automotive Company in Oman. All the Applications are fully Secured and runs under Windows Network. It is my pleasure to share my experience with others. Anything interesting that you would like to share with me, please do. My E-mail Address: aprpillai@msaccesstips.com


If you need a Demo of any of the Topic explained here, send me an E-mail to: aprpillai@msaccesstips.com
with the Topic Description, I shall try to send a sample database to you.


Access Tips | Email | Reports | Report Tricks | Graphs | Forms | Menus | Animation | Security | Internet | How TOs | Linking | Query | Progress Meter | Alerts | Process Tips | Access Functions |




Site Designed by:www.msaccesstips.com