Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I create a Bcc list using CDO

Posted on 2008-10-14
14
Medium Priority
?
301 Views
Last Modified: 2010-04-21
I have tried using the solution to the earlier question but I get a compiler error: Method or data member not found.   Can anyone help.
I would also like some advice on what to put in the recipient, as I don't really want one.
Code snippet attached
Thanks in advance.
Private Sub SendEmail(pRecipient)
    Dim myserver As clsAESeMailServer
    Dim mymsg As clsAESeMailMsg
    
    Set myserver = New clsAESeMailServer
    Set mymsg = New clsAESeMailMsg
    
    myserver.ServerAddress = Me!From.Column(0)
    myserver.AccountName = Me!From.Column(1)
    myserver.Password = Me!From.Column(2)
    
    Set mymsg.MailServer = myserver
    mymsg.From = Me!From.Column(1)
    mymsg.Recipient = pRecipient
    mymsg.Subject = CStr(Me!Subject)
    mymsg.BCC = CreateBCCList
    mymsg.Send
    
End Sub

Open in new window

0
Comment
Question by:CRB1609
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 38

Expert Comment

by:lherrou
ID: 22717471
CRB1609,

First of all, I presume you are storing your BCC recipients to CreateBCCList somewhere else in your code? Are you making sure your recipients are separated by semi-colons, and not by a combination of commas and spaces (which is the usual convention on, say, websites, etc)?

The only other thing I can think of is that it should be mymsg.Bcc = CreateBCCList - in other words, the cc part is lower case.

Cheers,
LHerrou





your string should look like this:
user@place.com;anotheruser@somewhere.com;user3@myemail.org
 
NOT like this:
user@place.com, anotheruser@somewhere.com, user3@myemail.org

Open in new window

0
 

Author Comment

by:CRB1609
ID: 22745926
The problem is that I don't get anywhere near constructing the string.  The code won't compile as it doesn't like lower case BCC and it converts to upper case automatically.
0
 
LVL 38

Expert Comment

by:lherrou
ID: 22746008
Can you show us that part of your code?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:CRB1609
ID: 22746377
Yes, it's a code snippet attached to the original question, shown above.
0
 
LVL 38

Expert Comment

by:lherrou
ID: 22746655
I don't see anything in there where you are creating your "CreateBCCList" list, though, the one that contains the email addresses you are BCCing to.
0
 

Author Comment

by:CRB1609
ID: 22746671
CreateBCCList is a function that creates and passes a string of the email address to be put in the Bcc field.  I didn't include it, as the problem is the code in the snippet doesn't compile.  It gives an error: 'Method or data member not found' and hightlights BCC in the line 'mymsg.BCC = CreateBCCList

0
 
LVL 38

Expert Comment

by:lherrou
ID: 22746689
Right, but I am wondering if that's the part that's failing, but the compiler doesn't know it until it hits that line and has an uninitialized variable.
0
 

Author Comment

by:CRB1609
ID: 22746735
Thanks.
I just tried that.  It doesn't get to the line.   The error appers with .BCC highlighted and the code stopped at the top of the sub on the line: Private Sub Private Sub SendEmail(pRecipient)
0
 
LVL 38

Accepted Solution

by:
lherrou earned 1000 total points
ID: 22748469
I'm reached what I can help with, but have asked for more experts to assist...
0
 
LVL 61

Expert Comment

by:mbizup
ID: 22749271

CRB1609,

Are you using aesmike's sample posted here?
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_23178018.html#20942816

Also, are you using Access VBA or Visual Basic?

clsAESeMailMsg is a class that he has written himself. You can find it by searching the project for the string "clsAESeMailMsg".

<'Method or data member not found'>
You are getting this error message because the class that Mike has written (clsAESeMailMsg) does not contain BCC as an option.

This is another way to use CDO that I posted in a seperate thread:

Call the function like this-
CDOSendEmail "MyFromAddress@MyEmail.com", "to@to.net", "bcc@bcc.net", "Interesting subject", "Totally Brilliant Message"


Function CDOSendEmail(varFrom As Variant, strTo As String, strBCC As String, strSubj As String, strMess As String)
    Dim strDefaultFrom  As String
    Dim objMess As Object
    Set objMess = CreateObject("CDO.Message")
      
    ' This is your default FROM address, and to be used if varFrom is Null or Empty
    strDefaultFrom = "DefaultAddress@MyEmail.com"
    
    ' Subject
    objMess.Subject = strSubj
    
    ' Message
    objMess.textbody = strMess
    
    ' Determine if varFrom is Null/Empty and use default address,
    ' otherwise use the From address passed through the function call
    objMess.From = IIf(Nz(varFrom, "") = "", strDefaultFrom, varFrom)
    
    ' To
    objMess.To = strTo
    
    ' BCC
    objMess.bcc = strBCC
    ' This is a simple example... you can do a lot more
    
    ' Send it
    objMess.send
    
    ' Clear the object variable
    Set objMess = Nothing
    
End Function
 

Open in new window

0
 

Author Comment

by:CRB1609
ID: 22754030
lherou.  Thanks for trying.  Much appreciated.

Mbizsetup.  Yes, I'm using aesmike's sample with Access VBA.  I'll try your code and get back to you.  Thank you very much.
0
 

Author Comment

by:CRB1609
ID: 22755678
mbizup
It compiled and ran through the code but didn't seem to do anything.  Is the code completely self contained?  Should I somehow specify the server, username, and password, etc.?
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 1000 total points
ID: 22759016
CRB1609,

The code I posted will send an Email from your default email account, but I haven't included any messages that indicate that the message was sent.
If you open your Sent Items folder, you should see your test message.
Let me know if this is what you needed...

0
 

Author Closing Comment

by:CRB1609
ID: 31506160
Thanks, guys.  It got beyond me but I appreciate the effort you put in.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question