Sorry, me again! I picked up the following very useful-looking bit of code from this site somewhere a while back. Now having need of something like it I decided to try it out. I can fully understand what it's doing, and so expected that it would work. But it hit a problem. The code is ... -
Private Sub Command0_Click()
-
-
'First, make sure that you have a Reference set to the
-
'Microsoft Outlook XX.X Object Library.
-
'Assuming you have a Table named tblEMailAddress, and it contains
-
'a Field to hold the E-Mail Addresses named [EAddr] :
-
-
Dim strEMail As String
-
Dim oOutlook As Object
-
Dim oMail As Object
-
Dim strAddr As String
-
Dim MyDB As DAO.Database
-
Dim rstEMail As DAO.Recordset
-
-
Set oOutlook = CreateObject("Outlook.Application")
-
Set oMail = oOutlook.CreateItem(0)
-
-
'Retrieve all E-Mail Addressess in tblEMailAddress
-
Set MyDB = CurrentDb
-
Set rstEMail = MyDB.OpenRecordset("TEST_EMAIL_TBL", dbOpenSnapshot, dbOpenForwardOnly)
-
-
With rstEMail
-
Do While Not .EOF
-
'Build the Recipients String
-
strEMail = strEMail & ![EAddr] & ";"
-
.MoveNext
-
Loop
-
End With
-
'--------------------------------------------------
-
-
With oMail
-
.To = Left$(strEMail, Len(strEMail) - 1) 'Remove Trailing ;
-
.Body = "Test E-Mail to Multiple Recipients"
-
.Subject = "Yada, Yada, Yada"
- .Send 'code halts here with error message
-
End With
-
-
Set oMail = Nothing
-
Set oOutlook = Nothing
-
-
rstEMail.Close
-
Set rstEMail = Nothing
-
-
End Sub
-
I have set a reference to the Outlook 12.0 object library, as per the initial comment.
The code halts at the line .Send, with the message "Application defined or Object defined error" which, in this case, presumably means Outlook doesn't like it.
Can anyone help me out with this?
4 1834
I recognize the code quite well, and it works fine. It must be something very simple that you are missing, so I sent an Attachment to point you in the right direction. Simple fill in a valid E-Mail Address or two in the [EAddr] Field of tblEMailAddress, then fire away.
Thank you. The long delay in replying to your kind help has been caused by my attempts to find out what I did/didn't do which you didn't/did do!
The mystery is not resolved!
Your code works, my code is exactly the same as yours except my .Body and .Send are capitalised and yours are not. Thinking this could not possibly make a difference, I tried to change my .Send to .send (try anything once!) but Access won't let me, it just recapitalises it. ... And my code still doesn't work!!!
I have checked the References, and note that your code doesn't actually have a ref to the Outlook 12.0 OL. I tried matching my code's refs exactly to yours, but it made no difference. Still getting same message at same line.
If I run your code in your form, it works. If I paste it into a button on my form, it doesn't???
I'm generally having a bad Microsoft Day! I won't bore you with the rest!
Two things, Juliet: - Replace .Send with .Display and see if if works. This will display the Outlook Window and you will manually have to Send.
- Upload the Database with the code so we can have a look at it.
- There is also a chance that Outlook may have some Security Mechanism in effect to prevent the automatic Sending of E-Mails.
- As far as capitalization goes, I doubt very much as to whether or not it would make any difference.
- You actually do not need a Reference to Outlok due to Late Binding.
Thank you.
1. Yes, that makes it work. I imagine this is most useful/reassuring way for user, anyway ... so they can see the message and really know it's gone!
2. I want to send you a little zipped db, but I'm not sure I've actually managed to attach it! It is strange, too.
3. I don't think this can be so, as it sent the message fine from your little form.
4. I'm sure it wouldn't make any difference! You know how it is when you are casting about for things to try!
5. I need to research the implications of late binding (generally)
Why (2) is strange ... I just added another button to your form with my code behind it. Now neither your button nor mine works unless I replace .send with .Display. Blurrrgh!
Meanwhile, another very strange thing maybe you can shed light on.
I have also tried using .SendObject to semi-automate the sending of an individual e-mail as per the following
Private Sub EBut_Click()
Dim jb As String
jb = "j.brown265@btinternet.com"
DoCmd.SendObject , , , jb, jb, jb, "Test message", "I am testing something", True
End Sub
This displays correctly ... a mail message with jb as the recipient, cc and bcc, the subject "Test Message" and body "I'm testing something" ... and the True makes it display the thing for editing before it goes off.
BUT, very strangely, it doesn't open the message in Outlook, but in my old Yahoo mail program that is still on the system but is not my default mail program any more (because, ironically enough, I couldn't get Access to talk to it!)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Bruce Davis |
last post by:
I'm having a problem on windows (both 2000 and XP) with a multi-threaded
tkinter gui application. The problem appears to be a deadlock condition
when a child thread pops up a
Pmw dialog window in...
|
by: Kostatus |
last post by:
I have a virtual function in a base class, which is then overwritten by a
function of the same name in a publically derived class. When I call the
function using a pointer to the derived class...
|
by: Refky Wahib |
last post by:
Hi
I need Technical Support
I finished a Great project using .Net and SQL Server and .Net Mobile
Control
My Business case is to implement this Program to accept about 1
Million concurrent...
|
by: Ian Stanley |
last post by:
Hi,
Continuing my strcat segmentation fault posting-
I have a problem which occurs when appending two sting literals using
strcat.
I have tried to fix it by writing my own function that does the...
|
by: Jon Davis |
last post by:
If I have a class with a virtual method, and a child class that overrides
the virtual method, and then I create an instance of the child class AS A
base class...
BaseClass bc = new ChildClass();...
|
by: Ammar |
last post by:
Dear All,
I'm facing a small problem.
I have a portal web site, that contains articles, for each article, the end
user can send a comment about the article.
The problem is:
I the comment length...
|
by: Dany |
last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by...
|
by: Mike Collins |
last post by:
I cannot get the correct drop down list value from a drop down I have on my
web form. I get the initial value that was loaded in the list.
It was asked by someone else what the autopostback was...
|
by: sherifbk |
last post by:
Problem description
==============
- I have 4 clients and 1 server (SQL server)
- 3 clients are Monitoring console 1 client is operation console
- Monitoring console collects some data from...
|
by: AceKnocks |
last post by:
I am working on a framework design problem in which I have to design a C++ based framework capable of solving three puzzles for now but actually it should work with a general puzzle of any kind and I...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
| |