473,698 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Skip blank email addresses when sending email from Outlook thru Access

9 New Member
This site is fantastic, first of all. Second of all, thank you for your time in this matter.

I have been using some code that was posted on here (I apologize for not being able to remember who) to send out emails from Outlook through Access. This has been working great until recently. When there is no entry in the email address field of my queries, the code crashes. How can I circumvent this error, without having to fill in the email address field?

Here is the code that I have been using:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSendEmail_Click()
  2. Dim rcdst As DAO.Recordset
  3. Dim strRecipients As String
  4. Dim strSubject As String
  5. Dim strBody As String
  6.  
  7. strSubject = txtSubject
  8. strBody = txtMsgBody
  9.  
  10. Set rcdst = CurrentDb.OpenRecordset(txtQryName, dbOpenForwardOnly)
  11. While Not rcdst.EOF
  12.         strRecipients = strRecipients & rcdst(txtEmailFieldName) & ";"
  13.         rcdst.MoveNext
  14. Wend
  15. DoCmd.SendObject acSendNoObject, , , , , strRecipients, strSubject, strBody & vbCr
  16. rcdst.Close
  17. Set rcdst = Nothing
  18.  
  19. End Sub
Aug 23 '07 #1
1 2574
Rabbit
12,516 Recognized Expert Moderator MVP
Have the query not return e-mail address that are null.
Aug 23 '07 #2

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

Similar topics

1
7751
by: Pablo | last post by:
Hi, there, I have a table which has a field (Email) populated with Email address. I am trying to send email using MS Outlook to those addresses. Everything works fine except that a warning message will pop up for every Email address stored in the table. I found that the following code caused the warning message: Recipients.Add(rst.Fields("Email")) Basically, the warning message has the following statment: "A program is trying to access...
1
5340
by: Jay McGrath | last post by:
Help - trying to send a simple text email with with as little user intervention. I am trying to create a button in my Access application that will automatically send a simple text email. It works except that I have two warning nuisances: 1) Program is trying to access email Addresses you have stored in Outlook. Allow access for ... 2) A program is trying to automatically send email on your behalf ... Heck, I am only trying to a send...
1
4163
by: Devonish | last post by:
I am composing an email with Access VB and then sending it from within Access. Everything works correctly (the email actually goes!) but Outlook ask some irritating questions that the user is required to answer. A summary of the relevant code is: Dim mailObj as Outlook.MailItem
5
4568
by: stemc © | last post by:
Hi there, In work, we often mail merge letters and post them to contacts. But more and more, we've been emailing information to people instead. So far, I've been writing a single generic email, then copying and pasting the email addresses into the address fields. I start the email off with 'Dear all...' But is there a way to 'email merge' this directly into outlook emails, in the same way we do for normal printed letters? This...
7
3554
by: Marcin | last post by:
Hello all! A few years ago I created a form with button which let me send an email with an attachment. It was created in Access 97. Now I would like to move this application into Access 2003. But when I did it, sending email code doesn`t work. Can you be so kind and give me the code how to send email with and without attachment in vb in Access 2003?? Thank you in advance
4
2173
by: acni | last post by:
hey just wondering if anyone could offer a bit of advice to me.i have a database with a list of contacts on it with a checkbox beside each one.i was wondering if it was possible to place a command button on the form so that when you click it it opens an email to send to all those with the ticked check box? Thanks in anticipation
8
2203
by: Chris Marsh | last post by:
Help... I am receiving this error "550 5.7.1 Unable to relay for synergytestacct@yahoo.com" when I try to send outside email directly from the website project. Keep in mind this works fine for local addresses within our domain but it is failing for outside address such as the example above. I created the above account for testing, I can send and receive email from my Outlook / Exchange 2000 account to this address however I cannot...
6
3497
by: Tim Marshall | last post by:
I am having one HELL of a time with sending pdfs that I generate. Outlook is not my preferred mail client but I have the wrethced thing installed so that I can use some late binding technique I discovered via Google groups. What happens is the infernal Outlook security warning appears. Irritating enough when you have dozens of notices going out, but about every second operation or fairly randomly, when I press "Yes", I get an outlook...
3
8959
by: IGD | last post by:
I don't know if this is the right place to post this or not. If not, could someone direct me elsewhere where I would find more information on how to solve my problem? Thanks! My problem is this: I am writing an application for work. This application sends a basic html email via SMTP to a group. In this group are individual people's emails, but also about 5 other groups. The problem is that the email is only getting received by (or sent...
0
8674
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
8604
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
9157
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...
1
8895
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
7728
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...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.