SendObject problems

G

Geoff

Sorry if this isn't the correct group for this but I'm not sure which Access
group is more relevant.

I'm having a problem using SendObject to send an email automatically from
within Access. I understand how it works and have had help with the code I
need to get it to do what I need. The problem is with the SendObject command
itself though. I know the syntax so I'm not asking that. It simply doesn't
open Outlook OR Outlook Express (tried both). 'Debug' doesn't show any
errors in my code either, so I don't understand it.

Any ideas please?
Thanks,
Geoff.
 
G

Geoff

By the way, I'm using Outlook 200 or Outlook Express 6, Access 2K and
Windows XP with SP1.

Geoff.
 
G

Geoff

Cheryl Fischer said:
You might want to check here:

ACC2000: SendObject Method Fails in Access 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;260819

In addition, I have seen a post or two in searching http://groups.google.com
that this was/is a known bug in Access 2000 which can be resolved by making
sure that all SPs and SRs are applied.


Hi Cheryl. I've done lots of Google searching and have found various ways of
doing the same thing, but I just realised today that the only bit in the
code that's not working is the SendObject part. I'm surprised I haven't come
across anything about this bug before, but I'll look at the link you gave me
and see if I can get it working.

Thanks for your help Cheryl, it's very much appreciated.

Geoff.
 
G

Geoff

Cheryl Fischer said:
Geoff,

You might want to check here:

ACC2000: SendObject Method Fails in Access 2000
http://support.microsoft.com/default.aspx?scid=kb;en-us;260819

In addition, I have seen a post or two in searching http://groups.google.com
that this was/is a known bug in Access 2000 which can be resolved by making
sure that all SPs and SRs are applied.


Hi again Cheryl,

I've tried what the page says and still no luck. It does seem to get further
though because at least I get a message box now asking me what profile I
want to use. I've setup a new profile for that user though and made it
default. Now, I don't get that message box but the email still doesn't
send-Outlook doesn't even load. I'm trying with both Outlook and OE by the
way, just in case one works and the other doesn't.

One thing I haven't tried is applying all SP's and SR's like you suggested.
Sorry to be thick but I don't know what they are! :)

Geoff.
 
J

Jim/Chris

This is the complete Email code. I obtained this from one
of the MVP's(Forgot wich one).
I have seen quite a bit of code for sending email. I have
tried many of them. If you are just sending an Access
report you can use the SendObject command. If attachments
are files of any type try the code below. The one below( I
have it stored as a function in a new module) has been the
most reliable for me with MS Outlook and Access 2000 and
can send up to 5 attachments or none. Also I am able to
pull from an open form email address of the recipient, CC,
BCC, and the subject and text and file name of the
attachment(s).
To reference data on an open form use
=[forms]![formname].[emailaddress]
=[forms]![formname].[subject]
=[forms]![formname].[attachment1]
ect.


Good Luck

Jim

Function SendEMail()
Dim strTo As String, strSubject As String, _
varBody As Variant, strCC As String, _
strBCC As String, strAttachment As String, _
strAttachment1 As String,strAttachment2 As String, _
strAttachment3 As String, strAttachment4 As String

strTo = "email address"
strSubject = "put subject here"
varBody = "put message for body here"
' Add more strattachments if needed and modify IF statement
' below
strAttachment = "attachment1"
strAttachment1 = "attachment2"
strAttachment2 = "attachment3"
strAttachment3 = "attachment4"
strAttachment4 = "attachment5"
'Start Outlook
Dim olApp As Outlook.Application
Set olApp = CreateObject("Outlook.Application")

'Logon
Dim olNs As Outlook.NameSpace
Set olNs = olApp.GetNamespace("MAPI")
olNs.Logon

'Send a message
Dim olMail As Outlook.MailItem
Set olMail = olApp.CreateItem(olMailItem)
'Fill Out and Send Message
olMail.To = strTo
olMail.CC = strCC
olMail.BCC = strBCC
olMail.Subject = strSubject
olMail.Body = varBody
' Modify these statements if more attachmewnts are needed
If Len(strAttachment) <> 0 Then
olMail.Attachments.Add (strAttachment)
If Len(strAttachment1) <> 0 Then
olMail.Attachments.Add (strAttachment1)
If Len(strAttachment2) <> 0 Then
olMail.Attachments.Add (strAttachment2)
If Len(strAttachment3) <> 0 Then
olMail.Attachments.Add (strAttachment3)
If Len(strAttachment4) <> 0 Then
olMail.Attachments.Add (strAttachment4)
End If
End if
End if
End if
End If
olMail.Send

Set olNs = Nothing
Set olMail = Nothing
Set olApp = Nothing

End Function

Jim
 
C

Cheryl Fischer

Hi Geoff,

First thing you might want to do is to make sure of exactly what you've got
installed on your system. Just open Access or any other of the Office
components and from the menu, click Help|About. The first line in the
window that opens shows the last SP or SR that was applied. For Microsoft
Office 2000, there are three SP/SRs. More information on service packs can
be found here:

http://support.microsoft.com/default.aspx?scid=FH;[LN];sp&
 
G

Geoff

Jim/Chris said:
This is the complete Email code. I obtained this from one
of the MVP's(Forgot wich one).
I have seen quite a bit of code for sending email. I have
tried many of them. If you are just sending an Access
report you can use the SendObject command. If attachments
are files of any type try the code below. The one below( I
have it stored as a function in a new module) has been the
most reliable for me with MS Outlook and Access 2000 and
can send up to 5 attachments or none. Also I am able to
pull from an open form email address of the recipient, CC,
BCC, and the subject and text and file name of the
attachment(s).
<snip>

Thanks Jim, that's very different from other code I've tried and I'll give
it a go later.

Thanks again,
Geoff.
 
G

Geoff

Cheryl Fischer said:
Hi Geoff,

First thing you might want to do is to make sure of exactly what you've got
installed on your system. Just open Access or any other of the Office
components and from the menu, click Help|About. The first line in the
window that opens shows the last SP or SR that was applied. For Microsoft
Office 2000, there are three SP/SRs. More information on service packs can
be found here:

http://support.microsoft.com/default.aspx?scid=FH;[LN];sp&


Hi Cheryl,

Oh now I know what you mean by 'SP' and 'SR'. :)

I haven't installed the latest actually so I will try that if the code
someone else in this thread has suggested doesn't work.

Thanks,
Geoff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top