473,569 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access/VBA - Sending Email Problem

10 New Member
Below is the code I'm trying to use to create a blank email with the bcc list populated from a query.

(1) I have tested the codes output of the "rcpts" field, and counted it as well - OK
(2) I've removed the "rcpts" field from the bcc option of the SendObject tag - OK
(3) I tried inserting the DoCmd.SendObjec t line into the loop and used the .Field("EmailNa me") as bcc - it worked OK

I need a single blank email, with all the rcpts addresses in the bcc field.
The code works great, until I insert the rcpts name in the bcc option. Am I using the wrong syntax to call the rcpts into the SendObject tag? Or is there a limit to the size of the bcc field for the SendObject tag? Please Help!

Thanks

Expand|Select|Wrap|Line Numbers
  1. Dim db As DAO.Database
  2. Dim rst As DAO.Recordset
  3. Dim rcpts As String
  4. Dim rcptscount As Integer
  5.  
  6.  
  7. Set db = CurrentDb
  8. Set rst = db.OpenRecordset("EmailInfo")
  9. rcpts = ""
  10. rcptscount = "0"
  11.  
  12. With rst
  13.     .MoveFirst
  14.     Do Until .EOF
  15.         rcpts = rcpts & .Fields("EmailName") & ";"
  16.         rcptscount = rcptscount + 1
  17.         .MoveNext
  18.     Loop
  19. End With
  20.  
  21. Debug.Print rcpts
  22. Debug.Print rcptscount
  23.  
  24. DoCmd.SendObject , , , "email@server.com", , rcpts, "Subject Text Here", "Message Text Inserted Right Here - Or Leave Blank", True
  25.  
  26. rst.Close
Mar 31 '07 #1
7 9328
Denburt
1,356 Recognized Expert Top Contributor
Look in the immediate window and check this debug statement something must be fishy with you email addresses or something. Maybe you can post it with dummy addresses so we can see what is going on.
Mar 31 '07 #2
Killer42
8,435 Recognized Expert Expert
...I need a single blank email, with all the rcpts addresses in the bcc field. The code works great, until I insert the rcpts name in the bcc option. Am I using the wrong syntax to call the rcpts into the SendObject tag? Or is there a limit to the size of the bcc field for the SendObject tag?
I'm not aware of any limit, and in fact haven't used the SendObject command. However, while Access does apply string-length limits in macros (I've run into that one) the suggested solution is to use VBA where the limits don't apply.

Could you give us a little more detail on the way in which it isn't working? Are you getting an error? Does it appear to work, but the mail never arrives? Etc.

But as far as the circumstances whichi stop it working - it's simply the use of multiple addresses, is that correct? Have you tried isolating the SendObject without the rest of your code, and just testing different values in Bcc?

Have you tried using your list delimiter (probably a comma) rather than semicolon, as mentioned in the online help for SendObject? Shouldn't be necessary, but may be worth a try.

By the way, I'm going to move this to the Access forum, as we should benefit from the weight of Access experience over there.
Apr 1 '07 #3
captainmorgan
10 New Member
I've been playing with the code, and I have it working as far as sending the first 255 characters of the BCC field. Now, I created a form with a MEMO field called BCC, which I have successfully transfered all the email addresses to, except again, they do not transfer to the Outlook Email.

Aaaahhhhh! I'm losing my mind over this. Is there better code than the SendObject, which will avoid the 255 character limitation?
Apr 2 '07 #4
Killer42
8,435 Recognized Expert Expert
I've been playing with the code, and I have it working as far as sending the first 255 characters of the BCC field. Now, I created a form with a MEMO field called BCC, which I have successfully transfered all the email addresses to, except again, they do not transfer to the Outlook Email.

Aaaahhhhh! I'm losing my mind over this. Is there better code than the SendObject, which will avoid the 255 character limitation?
I don't know, but hopefully someone else here might.

In the meantime, could you work around the problem in some way? For example, could you create a distribution list in Outlook and use that in the Bcc field instead of the individual addresses?

Or send the e-mail as many times as necessary to use up all of the addresses, in chunks of up to 255 characters? This would probably at least be an improvement over one e-mail per address.
Apr 2 '07 #5
ttamilvanan81
35 New Member
Look in the immediate window and check this debug statement something must be fishy with you email addresses or something. Maybe you can post it with dummy addresses so we can see what is going on.

Hai. I need to Send and Receive Email using Ms-Access and OutLook.
Now am using the following code for Send Email.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command20_Click()
  2.  
  3. Dim mess_body As String
  4. Dim appOutLook As Outlook.Application
  5. Dim MailOutLook As Outlook.MailItem
  6. Set appOutLook = CreateObject("Outlook.Application")
  7. Set MailOutLook = appOutLook.CreateItem(olMailItem)
  8.  
  9. Set appOutLook = CreateObject("Outlook.Application")
  10. Set MailOutLook = appOutLook.CreateItem(olMailItem)
  11.  
  12. With MailOutLook
  13. .BodyFormat = olFormatRichText
  14. .To = Me.Email_Address
  15.  
  16. .CC = Me.Cc_Address
  17. .BCC = Me.Bcc_Address
  18.  
  19. .Subject = Me.Mess_Subject
  20. .HTMLBody = Me.Mess_Text
  21.  
  22. If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
  23. .Attachments.Add (Me.Mail_Attachment_Path)
  24. End If
  25.  
  26. .Send
  27.  
  28. End With
  29.  
  30. Exit Sub
  31.  
  32. email_error:
  33. MsgBox "An error was encountered." & vbCrLf & "The error message is: " & 
  34.  
  35. Err.Description
  36. Resume Error_out
  37. Error_out:
  38.  
  39. End Sub
  40.  
This code, the attachment was working as, we type the location of the path manually. I need the Browse button to browse and select the file, the selected file path was stored in a text box.

And Also i need to Receive Email using Ms-Access and OutLook.

Can Anybody know this, please let me know.

Thanks
Tamilvanan
Apr 2 '07 #6
NeoPa
32,564 Recognized Expert Moderator MVP
You didn't post the results of your Debug.Print rcpts. I suspect it was very long, so no problem.
I would guess that it had a trailing ';' character though, which may (or may not) cause a problem. It wouldn't in the Outlook client, but who knows what it may fall over within VBA code.
Otherwise, I'd be very surprised if the length limit to a BCC parameter were as low as 255 chars.
Apr 2 '07 #7
Denburt
1,356 Recognized Expert Top Contributor
I need a single blank email, with all the rcpts addresses in the bcc field.
The code works great, until I insert the rcpts name in the bcc option. Am I using the wrong syntax to call the rcpts into the SendObject tag? Or is there a limit to the size of the bcc field for the SendObject tag? Please Help!
I am curious about why you want a blank email but that is a topic for later discussion. Are you getting any kind of error, if so what does it say? It would be nice to know the error number and description if you are getting one.

I am thinking you are possibly having an issue with one of the addresses. I know that I had a way of verifying email addresses but it is something I can't locate at this time. I just checked the help for sendobject and I noticed the following:

If the mail application can't identify the recipients' names, the message isn't sent and an error occurs.
I am wondering if you are on an exchange server or are you sending them through your local outlook client.

If you are on an exchange server take a look at this:
Exchange Emails

Or this:

Exchange

I did some research and someone else was complainging about a possible 255 character limit. I find this hard to believe but hey, could be. I like Killer's idea of "create a distribution list in Outlook" That sounds like a sound idea. I didn't see any hard documentation on a character limit but it doesn't surprise me. However if you are looking to possibly try another method then there are several at the following link. I personally like CDO and there are many examples of that out on the web.
Here are a couple of Microsoft Access Examples from Microsoft. I would stay away from the Access Basic (used in MS Access 2.0).

Email Examples

Hope some of this helps.
Apr 2 '07 #8

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

Similar topics

13
1851
by: Guy Hocking | last post by:
Hi there, i am creating a database driven login page. I am using code that has been successful in the past, however when i upload it to our web server it displys the following message in the page = ****** Microsoft OLE DB Provider for ODBC Drivers error '80004005' General error Unable to open
10
5554
by: MLH | last post by:
I print to a device that creates a PDF. Knowing the filename, how can I then embed the PDF into the body text of an OutLook Express outbound email & send to a specified address in a table? I want recipient addressees to see the report in the body text window of their email when they open it. I was thinking also about attaching the PDF file to...
1
4349
by: Atim | last post by:
I'm trying to create an email message in Novell Groupwise (from Access) which the user can edit before sending. Using the code below, I can create a message just fine, but the problem is that it gets sent out automatically, which is not what I want. If I comment out the Call Message.Send part of the code, it stores the message in the Work...
2
457
by: Tom Dauria | last post by:
I have a Access database application that sends email through Outlook. A few years ago we started having a problem where it would ask for each and every email being sent whether you want to give access to your email addresses in outlook and then something about sending mail on your behalf. Anyway we purchased software called Outlook...
3
2356
by: Strasser | last post by:
In Access2000 mass emailing worked perfectly (very powerful tool!). Doesn't work when using XP version of both Access and Outlook, even though I checked the box to ensure that I was sending the email. Any ideas? Thanks in advance.
1
2145
by: gemma.gill | last post by:
Hi There, I have a button on a form within access that sends a verification e- mail. My problem is that these e-mails are sending from individual user accounts rather than a genieric mailbox. Is there a way to do this? We are using MS Outlook each user has an account set up that gives them a personal mailbox and access to another...
14
2761
by: ARC | last post by:
Hello All, I have a major application for quoting and invoicing that is written in Access 97 (both front and back ends). I have a user base of over 300 customers, and currently I don't require that they have Access 97, as I use the access 97 runtime scripts from Sagekey software. The main problems I've seen with Access 97 are the built in...
16
2487
by: Ben Sehara | last post by:
Is there any way I can limit the access to my website? I have a site "A" and I want to allow access to it only from site "B" login user. If someone try to access site "A" directory, I want it redirected to site "B" for login. After login at site "B", you see the link to site"A". When you click it, you see login page for site "A". Is it...
9
3443
by: JoeP | last post by:
Hi All, How can I find the reason for such an error: Failure sending mail. Some Code... oMailMessage.IsBodyHtml = False oMailMessage.Body = cEmailBody Dim oSMTP As New SmtpClient oSMTP.Send(oMailMessage) (in this line I am getting the above err)
28
4404
tdw
by: tdw | last post by:
Hi all, I am trying to add a feature to our database that automates sending emails. When entering a new order, I want the option to send an email to the company the order came from, attaching a copy of our work order. The file that I want to attach is a rich text document created by Access and stored on our server. The creation of this...
0
7701
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...
0
7615
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...
0
7924
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. ...
0
6284
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...
1
5514
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...
0
3653
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...
0
3643
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2115
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
1
1223
muto222
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.