473,473 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Email Addresses - Ignore if null

4 New Member
Ok, so i am using this code (see below) to open up a new email message with all my listed clients e-mail addresses in the bcc field.

Pleblem is some of the clients do not have an email address so it comes up with an error.
How do i get Access to ignore these blank fields, where there are no email addresses entered and use the ones that are entered?

Code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command12_Click()
  2.  
  3.  
  4.     Dim cn As ADODB.Connection
  5.     Dim rs As ADODB.Recordset
  6.     Dim strEmail As String
  7.  
  8.     Set cn = CurrentProject.Connection
  9.     Set rs = New ADODB.Recordset
  10.  
  11.     rs.Open "CustomerT", cn
  12.  
  13.     With rs
  14.         Do While Not .EOF
  15.  
  16.             strEmail = strEmail & .Fields("Email") & ";"
  17.             .MoveNext
  18.     Loop
  19.         .Close
  20.     End With
  21.  
  22.  
  23. On Error GoTo Err_Command12_Click
  24.  
  25.     DoCmd.SendObject _
  26.     , _
  27.     , _
  28.     , _
  29.     , _
  30.     , _
  31.     ("" & strEmail), _
  32.     , _
  33.     , _
  34.     True
  35.  
  36. Exit_Command12_Click:
  37.     Exit Sub
  38.  
  39. Err_Command12_Click:
  40.     MsgBox Err.Description
  41.  
  42.     Resume Exit_Command12_Click
  43.  
  44. End Sub
Thanks
Oct 29 '09 #1
3 2620
ajalwaysus
266 Recognized Expert Contributor
I have one foot out the door, but here is a quick stab, refine your connection to only those who have email addresses.

Code:
Expand|Select|Wrap|Line Numbers
  1. rs.Open "SELECT * FROM CustomerT WHERE Email Is Not Null", cn
Hope this works.

-AJ
Oct 29 '09 #2
jammydodger2
4 New Member
Thank you so much. Works perfectly.

You are a Hero!
Cheers
Oct 29 '09 #3
Mmmel
52 New Member
Just thought I'd chime in with another possible solution. Would it work if you just ran a query from the table with the criteria "Is Not Null" for the email field and then based the code off the query instead? I had a similar problem and solved it this way.

Have a great day!

Mel
Feb 14 '10 #4

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

Similar topics

3
by: mark.greenbank | last post by:
Hi, I'm writing a small script that generates email and I've noticed that: 1) one should add the 'To' and 'CC' headers to the email message 2) one needs to specify the recipients in the...
117
by: Steevo | last post by:
Any suggestions as to the best programs for cloaking email addresses? Many thanks -- Steevo
12
by: Dag Sunde | last post by:
My understanding of regular expressions is rudimentary, at best. I have this RegExp to to a very simple validation of an email-address, but it turns out that it refuses to accept mail-addresses...
2
by: Saintor | last post by:
I have a string of email addresses with duplicates. like "abc@abc.com; cde@cde.com; abc@abc.com" If I use this string with sendobject, the receiver will get it only once which is perfect to...
1
by: Lyle Fairfield | last post by:
Option Explicit ' requires VBScript to be installed ' (maybe don't give this to your sugnificant other as ' it gets deleted addresses as well as current) ' obvious fixups needed '1. how get...
1
by: sxwend | last post by:
I am trying to use the following post results (http://www.thescripts.com/forum/thread189759.html) and add another requirement. I need to send the results to just the email addresses that the query...
16
by: Ed Bitzer | last post by:
Trying to send groups of email with program using System.Net.Mail. I do not clear MailMessage but repeatedly loop changing only the Bcc entries. Works fine if all addresses are valid. As a simple...
45
by: Dennis | last post by:
Hi, I have a text file that contents a list of email addresses like this: "foo@yahoo.com" "tom@hotmail.com" "jerry@gmail.com" "tommy@apple.com" I like to
7
by: ayush patel | last post by:
Hi everyone, I am writing ASP code to send email using SMTP.I am getting error '8004020f' at .Send. this seems to be a common error. my SMTP server relays to anonymous email addresses.there is...
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...
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...
1
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...
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?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.