Automate Outlook

  • Thread starter Alastair MacFarlane
  • Start date
A

Alastair MacFarlane

Dear All,

I am trying to send an email through Outlook NOT through the default Mailbox
but through another mailbox that I have total rights to. We are using Outlook
2000 and Access 97.

I am using the code below but it does not work:

Private Sub Command0_Click()
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem
Dim oFolders As MAPIFolder
Dim oInbox As MAPIFolder
Dim onMAPI As NameSpace
Set onMAPI = objOutlook.GetNamespace("MAPI")
Set oFolders = onMAPI.Folders("Mailbox - Balfour Helen")
Set oInbox = oFolders.Folders("Inbox")

'Check whether I have the correct Mailbox (and I do!)
MsgBox oInbox.Items.Count
'************* error here *************
Set objMail = oInbox.Items.Add(olMail)
With objMail
.To = "(e-mail address removed)"
.Subject = "Subject of mail message"
.Body = "Body of mail message"
.Send
End With
End Sub

It errors with the line "Set objMail = oInbox.Items.Add(olMail)".

?err.Number
-382271401
?err.Description
Could not complete the operation. One or more parameter values are not valid.

Can someone please advise me how to send an email from a specified
non-default mailbox.

Thanks again.

Alastair MacFarlane
 

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