![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
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 |
#5
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |