Dim bStarted As Boolean
Dim oOutlookApp As Object
Dim oItem As Object
Dim olMailItem As Object
Dim AttachmentPath As String
On Error Resume Next
If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
AttachmentPath = ActiveDocument.Path & "\" & ActiveDocument.Name
oItem.To = email_addr
oItem.Subject = get_subject(tl_fn)
oItem.Attachments.Add (AttachmentPath)
Err.Clear
ActiveDocument.Close
'
' oItem.send fail with err 91
'
If Not oItem.send Then
MsgBox "Failed to send mail to " & team_leader_name & ". ERR= " &
Err.Description
End If
If bStarted Then
oOutlookApp.Quit
End If
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Function get_subject(tl_fn As String)
get_subject = "Weekly status meeting summary - " & tl_fn & " - " &
Format(Date, "dd-MMM-yyyy")
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As general the On "Error Resume Next" is good after debugging
the script and after it is working.
"Avishay Balderman" <avishay_...@bmc.com> wrote in message
news:urst9u5...@corp.supernews.com...