Does it work if you add this?
Dim Ns as Outlook.Namespace
Set myObject = CreateObject("Outlook.Application")
Set Ns=myObject.GetNamespace("Mapi")

Signature
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Tue, 12 Feb 2008 16:14:31 +0000 schrieb Peter Hibbs:
> Hi, first post to this NG so feel free to point me in the right
> direction if this question is not appropriate.
[quoted text clipped - 3 lines]
> I am using the following function to send an email from Access via
> Outlook.
--------------------------------------------------------------------------------
> Public Function SendMail(strRecipients As String, strSubject As
> String, strBody As String) As String
[quoted text clipped - 34 lines]
>
> End Function
--------------------------------------------------------------------------------
> I am calling it like this from a button on a form :-
--------------------------------------------------------------------------------
> Private Sub btnEMail_Click()
>
[quoted text clipped - 3 lines]
>
> End Sub
--------------------------------------------------------------------------------
> The "EMail Address here" string is a valid email address.
>
[quoted text clipped - 32 lines]
>
> Peter Hibbs.
Peter Hibbs - 13 Feb 2008 12:10 GMT
Michael,
Unfortunately not, the same error occurs. The code at the start of the
function looks like this now, I assume that is what you intended.
---------------------------------------------------------------------------
Public Function SendMail(strRecipients As String, strSubject As
String, strBody As String) As String
Dim myObject As Object, myItem As Object
Dim vCount As Long
Dim Ns As Outlook.Namespace
On Error GoTo ProcError
Set myObject = CreateObject("Outlook.Application")
Set Ns = myObject.GetNamespace("Mapi")
Set myItem = myObject.CreateItem(0)
.... continues as shown in original post.
--------------------------------------------------------------------------
Any other thoughts.
Peter Hibbs.
>Does it work if you add this?
>
>Dim Ns as Outlook.Namespace
>Set myObject = CreateObject("Outlook.Application")
>Set Ns=myObject.GetNamespace("Mapi")
Michael Bauer [MVP - Outlook] - 14 Feb 2008 05:51 GMT
Peter, I cannot reproduce that error. If I add a call to Logon:
Set Ns = myObject.GetNamespace("Mapi")
Ns.Logon
everything works fine.

Signature
Best regards
Michael Bauer - MVP Outlook
Use Outlook Categories? This is Your Tool:
<http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6>
Am Wed, 13 Feb 2008 12:10:30 +0000 schrieb Peter Hibbs:
> Michael,
>
> Unfortunately not, the same error occurs. The code at the start of the
> function looks like this now, I assume that is what you intended.
---------------------------------------------------------------------------
> Public Function SendMail(strRecipients As String, strSubject As
> String, strBody As String) As String
[quoted text clipped - 20 lines]
>>Set myObject = CreateObject("Outlook.Application")
>>Set Ns=myObject.GetNamespace("Mapi")
Peter Hibbs - 14 Feb 2008 21:44 GMT
Michael,
Brilliant, that works perfectly. I still need to test it with multiple
recipients and attachments but I guess that should still work OK.
Not sure why adding the Logon function should make all the difference.
Hopefully it will work OK on my client's system (Access/Outlook 2000)
which I will check next week.
Anyway, thanks again.
Peter Hibbs.
>Peter, I cannot reproduce that error. If I add a call to Logon:
>
>Set Ns = myObject.GetNamespace("Mapi")
>Ns.Logon
>
>everything works fine.