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

Skip blank email addresses when sending email from Outlook thru Access

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 2554
Rabbit
12,516 Expert Mod 8TB
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
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...
1
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...
1
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...
5
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...
7
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....
4
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...
8
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...
6
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...
3
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:...
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
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,...
0
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...
0
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,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.