473,671 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Linking Ms acces with an e-amil package

1 New Member
Wondering if its possible to link a table with e-mail addresses in it, with an e-mail package, sending out a standardised e-mail to certain people within the database table.

Many Thanks

ajc
Oct 23 '07 #1
1 1356
Kevin Wilcox
68 New Member
Yes it is, you can send through outlokk. Here's some sample code, you'll need to modify it to suit.

Expand|Select|Wrap|Line Numbers
  1. Public Sub SendOutlookMessage( _
  2.     strEmailAddress As String, _
  3.     strEmailCCAddress As String, _
  4.     strEmailBccAddress As String, _
  5.     strSubject As String, _
  6.     strMessage As String, _
  7.     blnDisplayMessage As Boolean, _
  8.     Optional strAttachmentFullPath As String)
  9.  
  10. '* Copy this code and paste it into a new Access
  11. '* Module. Click Tools > References and make sure
  12. '* that "Microsoft Office Outlook x.0 Object Library"
  13. '* is checked.
  14. '*
  15. '* This subroutine sends an e-mail message through
  16. '* MS Outlook. If the "blnDisplayMessage" parm is
  17. '* set to "False", the message is placed in the
  18. '* Outlook Outbox. "True" displays the message, and
  19. '* user will have to click "Send" to send it.
  20. '*
  21. '* Ex.:
  22. '*
  23. '* SendOutlookMessage _
  24. '*      "john@doe.com", _
  25. '*      "ccJane@doe.com", _
  26. '*      "bccSue@doe.com", _
  27. '*      "Subject", _
  28. '*      "Body of Message", _
  29. '*      False, _
  30. '*      "C:\My Documents\MyAttachmentFile.txt"
  31.  
  32. Dim objApp As Outlook.Application
  33. Dim objOutlookMsg As Outlook.MailItem
  34. Dim objOutlookRecipient As Outlook.Recipient
  35. Dim objOutlookAttach As Outlook.Attachment
  36. Dim blnOutlookInitiallyOpen As Boolean
  37. Dim strProcName As String
  38.  
  39. On Error Resume Next
  40. strProcName = "SendOutlookMessage"
  41.  
  42. blnOutlookInitiallyOpen = True
  43. Set objApp = GetObject(, "Outlook.Application")
  44. If objApp Is Nothing Then
  45.     Set objApp = CreateObject("Outlook.Application")
  46.     '* Outlook wasn't open when this function started.
  47.     blnOutlookInitiallyOpen = False
  48. End If
  49. If Err <> 0 Then Beep: _
  50.     MsgBox "Error in " & strProcName & " (1): " _
  51.         & Err.Number & " - " & Err.Description: _
  52.     Err.Clear: _
  53.     GoTo Exit_Section
  54.  
  55. 'Create the message
  56. Set objOutlookMsg = objApp.CreateItem(olMailItem)
  57. If Err <> 0 Then Beep: _
  58.     MsgBox "Error in " & strProcName & " (2): " _
  59.         & Err.Number & " - " & Err.Description: _
  60.     Err.Clear: _
  61.     GoTo Exit_Section
  62.  
  63. With objOutlookMsg
  64.     Set objOutlookRecipient = .Recipients.Add(strEmailAddress)
  65.     objOutlookRecipient.Type = olTo
  66.     If strEmailCCAddress = "" Then
  67.     Else
  68.         Set objOutlookRecipient = .Recipients.Add(strEmailCCAddress)
  69.         objOutlookRecipient.Type = olCC
  70.     End If
  71.     If strEmailBccAddress = "" Then
  72.     Else
  73.         Set objOutlookRecipient = .Recipients.Add(strEmailBccAddress)
  74.         objOutlookRecipient.Type = olBCC
  75.     End If
  76.     .Subject = strSubject
  77.     .Body = strMessage
  78.  
  79.     '* Add attachments
  80.     If Not IsMissing(strAttachmentFullPath) Then
  81.         If Trim(strAttachmentFullPath) = "" Then
  82.         Else
  83.             Set objOutlookAttach = .Attachments.Add(strAttachmentFullPath)
  84.             If Err <> 0 Then Beep: _
  85.                 MsgBox "Error in " & strProcName & " (3): " _
  86.                     & Err.Number & " - " & Err.Description: _
  87.                 Err.Clear: _
  88.                 GoTo Exit_Section
  89.         End If
  90.     End If
  91.  
  92.     If blnDisplayMessage Then
  93.         .Display
  94.     Else
  95.         '* Send message by putting it in the Outbox
  96.         .Send
  97.     End If
  98. End With
  99.  
  100. If Err <> 0 Then Beep: _
  101.     MsgBox "Error in " & strProcName & " (99): " _
  102.         & Err.Number & " - " & Err.Description: _
  103.     Err.Clear: _
  104.     GoTo Exit_Section
  105.  
  106. Exit_Section:
  107.     On Error Resume Next
  108.     If Not blnOutlookInitiallyOpen Then
  109.        objApp.Quit
  110.     End If
  111.     Set objApp = Nothing
  112.     Set objOutlookMsg = Nothing
  113.     Set objOutlookAttach = Nothing
  114.     Set objOutlookRecipient = Nothing
  115.     On Error GoTo 0
  116. End Sub
Oct 24 '07 #2

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

Similar topics

4
2762
by: Kona | last post by:
Hello, I would like to known if it is possible to limit acces to a UDB database on Solaris system through db2connect to only specified clients ? My client is a db2connect on Windows platform. Thank you
1
1565
by: TTD_hck | last post by:
Hello, I need suggestions for the following. I have a acces 97 database and with a script command in acces 97, I can e-mail a file via outllok. I do this with the folowing command in Acces 97: DoCmd.SendObject acReport, "overboeken uitgesneden", acFormatRTF, "info@mailadres.nl" , , , " ret, uit" & Forms....... This command worked fine with oulook 97. But since i installend outlook XP
0
2240
by: gasturbtec | last post by:
please help im new at access programming and i just got this project dropped in my lap because the old programmer quit. i've been doing ok so far but now i need to add code to an existing database that is used to connect to other databases and generate reports. below is sample code of how the database does the linking i hope i give you enough info to help me but if not let me know and i will give more. Sub txtShipDataFileSub() Dim...
0
1169
by: John Smith | last post by:
I am currently using excel to manage a small database. The problem is my database is getting big and I need more then the 65000 lines excel can have. I have considered access but it lacks some important built-in features from excel. For exemple: - Easily Add multiples similar entry with incremental numbers or lets say the same line 40 times. Ok lets say I have somes book numbered 1 - 500. Currently I don't know
1
1607
by: Admir Hod?ic via AccessMonster.com | last post by:
I use some old fashion program whit DBF files and now i step by step moving thth to acces. Problem occurs when i try to link DBF tables whit MEMO FILED wich requvest file whit ''name''.ftp extension whic reprezent that memo filed. That kind of DBF file i cant link or import. Anyone have fix for that is there any program to i can delete that filed before i link table or is there any good option for that. thanx a lot sory on my bed english --...
5
2444
by: Mrozu | last post by:
Hi I have frm1. On this form button.Click code for this button is: Dim frm2 as New frm2 frm2.show So after click, frm2 form is shown.
3
2044
by: tomPee | last post by:
Hi, I have the following problem: I am trying to make some sort of base class menu that i can then use to derive other menu's from. Those menu's should then be able to interact with each other. And, i have most of the idea figured out and I thought out how i want to do it. But when i started coding i found a slight... difficulty. It might be easy to overcome, but google let me down :( and my own imagination made one happy jump, but...
2
1177
by: throwerm72 | last post by:
I currently have and Access DB that has imported/linked tables from a MySQL databse running on a server (using and ODBC connection). I need to link the another Access DB with the same tables to my existing Access DB (pulling from a MySQL server). Essentially i am linking an existing Acces DB to and an Existing MySQL DB using another access db to join the two. Essetialy a user would be able to make change in the exsiting Access db which...
6
1448
by: zaankanter | last post by:
Hi, This my problem. After distribution of my acces-application I want the new user to be able to enter his Name-adress-etc values, in a one-row table called program-variables. These will be used tot print on reports etc. I want this to be a one-time event. This will help to avoid illegal re-distibution. My idea is that before updating the values ther is a check: are the fields null or not? If not the action should be canceled. In more...
3
1906
by: bilalkhan | last post by:
Hello I m using MS Acces 2007, I need to create a form through which a user can enter all the parameter values in the form and these values will automatically picked by a query: Here is the query which i want to link with a form INSERT INTO ( , , , , , , , Cases, Premium, , ) SELECT ., ., ., ., ., ., ., .Cases, .Premium, ., . FROM
0
8474
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8392
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8912
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8819
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8597
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8669
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4403
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2809
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.