dbTalk Databases Forums  

Interfacing with Outlook

comp.databases.ms-access comp.databases.ms-access


Discuss Interfacing with Outlook in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Phil
 
Posts: n/a

Default Interfacing with Outlook - 06-19-2010 , 11:37 AM






The following has always worked with Access 2000 / Outlook 2000

SendEMail:
'Get Outlook if it's running
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
FlgQuit = False
Else
Set oOutlookApp = CreateObject("Outlook.Application")
FlgQuit = True
End If
On Error GoTo 0
Err.Clear

On Error GoTo Err_EMailFile

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(OLMailItem)

With oItem
'Set the recipient for the new email
.To = MailTo
'Set the recipient for a copy
.CC = ""
'Set the subject
.Subject = Subject
'Attachment is the attachment
.HTMLBody = BodyText
.ReadReceiptRequested equested = MsgRead ' Flag for message read

If AttachmentsFound = True Then
For For j = LBound(Attach()) To UBound(Attach()) ' No of attachments
If Not IsMissing(Attach(j)) Then
If Attach(j) > "" Then
Set olAttachment = .Attachments.Add(Attach(j))
End If
End If
Next j
End If

.Send
End With
EMailFile = 2 ' OK

If FlgQuit = True Then
oOutlookApp.Application.Quit
Set oOutlookApp = Nothing
Else
Set oOutlookApp = Nothing
End If

CleanUp:
Set oItem = Nothing
Set oOutlookApp = Nothing
Exit Function

Err_EMailFile:
If Err = 287 Then ' No to send email
MsgBox "Email not sent", vbInformation
EMailFile = 1 ' cancelled
ElseIf seIf Err = 9 Then ' Subscript out of range - so no attachments
Resume SendEMail
ElseIf Err = -2147467259 Then ' Can't find contact
EMailFile = 3
Else
MsgBox MsgBox "Email not sent " & Err.Description, vbCritical, "Email not
sent" End If
GoTo CleanUp


With Office 2010 I am getting an error (-2147467259 ) Outlook does not
recognize one or more names.

Any ideas where to look

Thanks

Phil

Reply With Quote
  #2  
Old   
Salad
 
Posts: n/a

Default Re: Interfacing with Outlook - 06-19-2010 , 12:00 PM






Phfil wrote:

If it has always worked, and it doesn't now, and you don't know where
the error occurs then you need to find what initiates the error.

You could always insert the word
STOP
and step thru the code and determine the error entry point.

You do have a line
For For j....
and
ReadReceiptRequested equested = MsgRead
in this post that don't make sense. Is that from posting the message
here or does exist in your program?

Quote:
The following has always worked with Access 2000 / Outlook 2000

SendEMail:
'Get Outlook if it's running
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
FlgQuit = False
Else
Set oOutlookApp = CreateObject("Outlook.Application")
FlgQuit = True
End If
On Error GoTo 0
Err.Clear

On Error GoTo Err_EMailFile

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(OLMailItem)

With oItem
'Set the recipient for the new email
.To = MailTo
'Set the recipient for a copy
.CC = ""
'Set the subject
.Subject = Subject
'Attachment is the attachment
.HTMLBody = BodyText
ReadReceiptRequested equested = MsgRead ' Flag for message read

If AttachmentsFound = True Then
For For j = LBound(Attach()) To UBound(Attach()) ' No of attachments
If Not IsMissing(Attach(j)) Then
If Attach(j) > "" Then
Set olAttachment = .Attachments.Add(Attach(j))
End If
End If
Next j
End If

.Send
End With
EMailFile = 2 ' OK

If FlgQuit = True Then
oOutlookApp.Application.Quit
Set oOutlookApp = Nothing
Else
Set oOutlookApp = Nothing
End If

CleanUp:
Set oItem = Nothing
Set oOutlookApp = Nothing
Exit Function

Err_EMailFile:
If Err = 287 Then ' No to send email
MsgBox "Email not sent", vbInformation
EMailFile = 1 ' cancelled
ElseIf seIf Err = 9 Then ' Subscript out of range - so no attachments
Resume SendEMail
ElseIf Err = -2147467259 Then ' Can't find contact
EMailFile = 3
Else
MsgBox MsgBox "Email not sent " & Err.Description, vbCritical, "Email not
sent" End If
GoTo CleanUp


With Office 2010 I am getting an error (-2147467259 ) Outlook does not
recognize one or more names.

Any ideas where to look

Thanks

Phil

Reply With Quote
  #3  
Old   
Phil
 
Posts: n/a

Default Re: Interfacing with Outlook - 06-19-2010 , 01:13 PM



On 19/06/2010 18:00:17, Salad wrote:
Quote:
Phfil wrote:

If it has always worked, and it doesn't now, and you don't know where
the error occurs then you need to find what initiates the error.

You could always insert the word
STOP
and step thru the code and determine the error entry point.

You do have a line
For For j....
and
ReadReceiptRequested equested = MsgRead
in this post that don't make sense. Is that from posting the message
here or does exist in your program?

The following has always worked with Access 2000 / Outlook 2000

SendEMail:
'Get Outlook if it's running
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
FlgQuit = False
Else
Set oOutlookApp = CreateObject("Outlook.Application")
FlgQuit = True
End If
On Error GoTo 0
Err.Clear

On Error GoTo Err_EMailFile

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(OLMailItem)

With oItem
'Set the recipient for the new email
.To = MailTo
'Set the recipient for a copy
.CC = ""
'Set the subject
.Subject = Subject
'Attachment is the attachment
.HTMLBody = BodyText
ReadReceiptRequested equested = MsgRead ' Flag for message read

If AttachmentsFound = True Then
For For j = LBound(Attach()) To UBound(Attach()) ' No of attachments
If Not IsMissing(Attach(j)) Then
If Attach(j) > "" Then
Set olAttachment = .Attachments.Add(Attach(j))
End If
End If
Next j
End If

.Send
End With
EMailFile = 2 ' OK

If FlgQuit = True Then
oOutlookApp.Application.Quit
Set oOutlookApp = Nothing
Else
Set oOutlookApp = Nothing
End If

CleanUp:
Set oItem = Nothing
Set oOutlookApp = Nothing
Exit Function

Err_EMailFile:
If Err = 287 Then ' No to send email
MsgBox "Email not sent", vbInformation
EMailFile = 1 ' cancelled
ElseIf seIf Err = 9 Then ' Subscript out of range - so no attachments
Resume SendEMail
ElseIf Err = -2147467259 Then ' Can't find contact
EMailFile = 3
Else
MsgBox MsgBox "Email not sent " & Err.Description, vbCritical, "Email not
sent" End If
GoTo CleanUp


With Office 2010 I am getting an error (-2147467259 ) Outlook does not
recognize one or more names.

Any ideas where to look

Thanks

Phil

Tha\nks salad, as usual you are trying to bail me out

The line in the program is
.ReadReceiptRequested d = MsgRead ' Flag for message read

So I presume it got corrupted in the newsgroup.

All runs happily with the Outlook fields in with valid data.
The .To field (MailTo) is set to "Phil Stanton" and I guess for som reason it
is not finding me (Neither is it finding "Stanton Phil" My name is in the
list of contacts The error occurs at the .Send line

Thanks

Phil

Reply With Quote
  #4  
Old   
Salad
 
Posts: n/a

Default Re: Interfacing with Outlook - 06-19-2010 , 03:01 PM



Phil wrote:

Quote:
On 19/06/2010 18:00:17, Salad wrote:

Phfil wrote:

If it has always worked, and it doesn't now, and you don't know where
the error occurs then you need to find what initiates the error.

You could always insert the word
STOP
and step thru the code and determine the error entry point.

You do have a line
For For j....
and
ReadReceiptRequested equested = MsgRead
in this post that don't make sense. Is that from posting the message
here or does exist in your program?


The following has always worked with Access 2000 / Outlook 2000

SendEMail:
'Get Outlook if it's running
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
FlgQuit = False
Else
Set oOutlookApp = CreateObject("Outlook.Application")
FlgQuit = True
End If
On Error GoTo 0
Err.Clear

On Error GoTo Err_EMailFile

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(OLMailItem)

With oItem
'Set the recipient for the new email
.To = MailTo
'Set the recipient for a copy
.CC = ""
'Set the subject
.Subject = Subject
'Attachment is the attachment
.HTMLBody = BodyText
ReadReceiptRequested equested = MsgRead ' Flag for message read

If AttachmentsFound = True Then
For For j = LBound(Attach()) To UBound(Attach()) ' No of attachments
If Not IsMissing(Attach(j)) Then
If Attach(j) > "" Then
Set olAttachment = .Attachments.Add(Attach(j))
End If
End If
Next j
End If

.Send
End With
EMailFile = 2 ' OK

If FlgQuit = True Then
oOutlookApp.Application.Quit
Set oOutlookApp = Nothing
Else
Set oOutlookApp = Nothing
End If

CleanUp:
Set oItem = Nothing
Set oOutlookApp = Nothing
Exit Function

Err_EMailFile:
If Err = 287 Then ' No to send email
MsgBox "Email not sent", vbInformation
EMailFile = 1 ' cancelled
ElseIf seIf Err = 9 Then ' Subscript out of range - so no attachments
Resume SendEMail
ElseIf Err = -2147467259 Then ' Can't find contact
EMailFile = 3
Else
MsgBox MsgBox "Email not sent " & Err.Description, vbCritical, "Email not
sent" End If
GoTo CleanUp


With Office 2010 I am getting an error (-2147467259 ) Outlook does not
recognize one or more names.

Any ideas where to look

Thanks

Phil


Tha\nks salad, as usual you are trying to bail me out

The line in the program is
ReadReceiptRequested d = MsgRead ' Flag for message read

So I presume it got corrupted in the newsgroup.

All runs happily with the Outlook fields in with valid data.
The .To field (MailTo) is set to "Phil Stanton" and I guess for som reason it
is not finding me (Neither is it finding "Stanton Phil" My name is in the
list of contacts The error occurs at the .Send line

Thanks

Yeah. I noticed your error code was in your error trap for contact not
found. Perhaps you might want to ask about the code in an Outlook
newsgroup like microsoft.public.outlook or
microsoft.public.outlook.general and also note where the error occurs
for them.


> Phil

Reply With Quote
  #5  
Old   
Phil
 
Posts: n/a

Default Re: Interfacing with Outlook - 06-20-2010 , 03:15 AM



On 19/06/2010 21:01:43, Salad wrote:
Quote:
Phil wrote:

On 19/06/2010 18:00:17, Salad wrote:

Phfil wrote:

If it has always worked, and it doesn't now, and you don't know where
the error occurs then you need to find what initiates the error.

You could always insert the word
STOP
and step thru the code and determine the error entry point.

You do have a line
For For j....
and
ReadReceiptRequested equested = MsgRead
in this post that don't make sense. Is that from posting the message
here or does exist in your program?


The following has always worked with Access 2000 / Outlook 2000

SendEMail:
'Get Outlook if it's running
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err.Number = 0 Then
FlgQuit = False
Else
Set oOutlookApp = CreateObject("Outlook.Application")
FlgQuit = True
End If
On Error GoTo 0
Err.Clear

On Error GoTo Err_EMailFile

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(OLMailItem)

With oItem
'Set the recipient for the new email
.To = MailTo
'Set the recipient for a copy
.CC = ""
'Set the subject
.Subject = Subject
'Attachment is the attachment
.HTMLBody = BodyText
ReadReceiptRequested equested = MsgRead ' Flag for message read

If AttachmentsFound = True Then
For For j = LBound(Attach()) To UBound(Attach()) ' No of attachments
If Not IsMissing(Attach(j)) Then
If Attach(j) > "" Then
Set olAttachment = .Attachments.Add(Attach(j))
End If
End If
Next j
End If

.Send
End With
EMailFile = 2 ' OK

If FlgQuit = True Then
oOutlookApp.Application.Quit
Set oOutlookApp = Nothing
Else
Set oOutlookApp = Nothing
End If

CleanUp:
Set oItem = Nothing
Set oOutlookApp = Nothing
Exit Function

Err_EMailFile:
If Err = 287 Then ' No to send email
MsgBox "Email not sent", vbInformation
EMailFile = 1 ' cancelled
ElseIf seIf Err = 9 Then ' Subscript out of range - so no attachments
Resume SendEMail
ElseIf Err = -2147467259 Then ' Can't find contact
EMailFile = 3
Else
MsgBox MsgBox "Email not sent " & Err.Description, vbCritical, "Email not
sent" End If
GoTo CleanUp


With Office 2010 I am getting an error (-2147467259 ) Outlook does not
recognize one or more names.

Any ideas where to look

Thanks

Phil


Tha\nks salad, as usual you are trying to bail me out

The line in the program is
ReadReceiptRequested d = MsgRead ' Flag for message read

So I presume it got corrupted in the newsgroup.

All runs happily with the Outlook fields in with valid data.
The .To field (MailTo) is set to "Phil Stanton" and I guess for som reason it
is not finding me (Neither is it finding "Stanton Phil" My name is in the
list of contacts The error occurs at the .Send line

Thanks

Yeah. I noticed your error code was in your error trap for contact not
found. Perhaps you might want to ask about the code in an Outlook
newsgroup like microsoft.public.outlook or
microsoft.public.outlook.general and also note where the error occurs
for them.


Phil

Hi Salas.

Definately think it is an Outlook problem, as if I change the MailTo from
"Phil Stanton" to "phil (AT) stantonf (DOT) ...co.uk" there is no problem. obviously the
bit of Outlook that finds the email addresses from the name is not working
properly

Will check with outlook people.
Thanks for your help

Phil

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.