Results 1 to 2 of 2

Thread: [RESOLVED] Outlook 2003 - trying to have a check on a mail item

Hybrid View

  1. #1

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Resolved [RESOLVED] Outlook 2003 - trying to have a check on a mail item

    Hi,

    My boss has expressed a wish for mail to tell him when he hasn't got an attachment on it but has the word attachment in the mail (ie please find an attachment of a spreadsheet....blah blah).

    So I thought I'd have a go seeing as there is a VBA section to Outlook.

    I started on the outlook application > thissession code module and started to make progress (ie a msgbox check) but for some reason the msgbox comes from the main outlook window, which is not highlighted from the mail item. Great. Vivsble property isn't there etc... usual. Not a huge problem, and something I can look at later.

    Then Outlook died (pop up outlook had a problem and dr watson is trying to bring it back from the dead).

    Re ran outlook, but now the events coding is not running. Its ignoring it completely.

    Is there something I've missed?

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  2. #2

    Thread Starter
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: [RESOLVED] Outlook 2003 - trying to have a check on a mail item

    For those of you who are interested - it reset the macro security to high thus ignored the code as it is unsigned.

    Dropping the security to medium, and saying yes it will run it.
    Code:
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
        Dim itm As MailItem
        
        On Error Resume Next
        
        Application.ActiveWindow.Display
    
    '---- brings up a new instance that is created for the mail item (for some reason)
        'Item.Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Display
    
        If (Item.Body Like "*attachment*" Or Item.Body Like "*attached*") And Item.Attachments.Count = 0 Then
            Cancel = (MsgBox("Are you sure you want to send this email without any attachments?", vbYesNo + vbQuestion, "Uhhh") = vbNo)
        End If
        
        If Err.Number <> 0 Then
            MsgBox "Error : " & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbExclamation, "Error"
            Err.Clear
        End If
        
        If Cancel Then Item.Display
    End Sub
    This was what I was trying to do

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width