Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel: Unable to trap 287 error with Outlook Security Dialog

Hi,

I would very much appreciate it if someone can save my sanity and help
me with the following problem.

I am sending automated e-mails using the Outlook object model from
Excel. The problem being when 'No' is clicked on the Outlook Security
Dialog Box I am unable to trap the error in Excel and my application
falls over with Error: '287' .

Here is my code...

Public Function SendEmailToGroup(strAttachPathFilename As String,
strGroupName As String) As Boolean
On Error GoTo ErrorMsgs

Dim OL As Object ' Outlook instantiation
Dim EmailItem As Object ' A new mail item (e-mail)

Dim oEmailGroup As EmailGroup
Dim strRecipientList As String

Set OL = CreateObject("Outlook.Application") ' New Outlook application

Set EmailItem = OL.CreateItem(olMailItem) ' new MailItem

Set oEmailGroup = New EmailGroup

If Not oEmailGroup.LoadByName(strGroupName) Then
Err.Raise ERR_BAD_EMAIL_GROUPNAME, , "Email group " & strGroupName
& " was not found"
End If

strRecipientList = "" & oEmailGroup.GetRecipientList

With EmailItem
.Subject = "Five Overnights"
.Body = strEmailContent
.To = "" & strRecipientList
.Importance = olImportanceNormal
.Attachments.Add "" & strAttachPathFilename


If EmailItem.Send Then

End With


SendEmailToGroup = True


strRecipientList = ""
Set EmailItem = Nothing
Set OL = Nothing
Set oEmailGroup = Nothing

Exit Function

ErrorMsgs:


Err.Clear

MsgBox "E-mail Configuration incorrect. Workbook not sent." _
& vbCrLf & vbCrLf & " Workbook saved in default save directory.",
vbExclamation, "" & strGroupName & ": Error Sending Report"

SendEmailToGroup = False

strRecipientList = ""
Set EmailItem = Nothing
Set OL = Nothing
Set oEmailGroup = Nothing


Exit Function

End Function


Thanks,

Lex

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to change security in Excel 2007 Aare New Users to Excel 1 June 26th 08 10:35 PM
Error Handling - On Error GoTo doesn't trap error successfully David Excel Programming 9 February 16th 06 05:59 PM
Excel Spreadsheet email attachment unable to open in Outlook Expr. Joanne from Tiffin, Oh Excel Discussion (Misc queries) 1 April 23rd 05 12:21 AM
disregard the Outlook dialog box sending task/eMail from Excel 2003 jC! Excel Programming 6 May 28th 04 12:38 AM
Prevent dialog - Prevents Sending Excel File From Outlook JP[_7_] Excel Programming 7 August 18th 03 06:25 PM


All times are GMT +1. The time now is 04:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"