Outlook VB Script

Author Message
Untalented

  • Total Posts : 4
  • Scores: 0
  • Reward points : 0
  • Joined: 9/14/2011
  • Status: offline
Outlook VB Script Wednesday, September 14, 2011 7:36 AM (permalink)
0
Hi,
 
I have a script I've pieced together over time. Recently a plugin we need to use in Outlook has caused some issues. Basically we get prompted twice because when the plugin is used the e-mail ends up being destroyed and re-created with a specific attachment filename. At this point the user is prompted again. I've tried to work in a For loop to skip the script if it finds this attachment. However, when I added the For loop it just seems to skip the entire script. I have limited experience with VBScripting and so I'm sure it's an issue with my syntax or usage. See script below:
 

Private Sub Application_ItemSend _
(ByVal Item As Object, Cancel As Boolean)
Dim strMsg As String
Dim Atmt As Variant
 
If Item.Class = "43" Then
For Each Atmt In Item.Attachments
If VBA.Right(Atmt.FileName, 3) = ".sf" Then
GoTo NonEmailError
End If
Next Atmt
If Item.CC = "" Then
strMsg = "To recipients: " & Item.To & vbCrLf & _
"Are you sure you want to send this message?"
Else
strMsg = "To recipients: " & Item.To & vbCrLf & _
"Cc recipients: " & Item.CC & vbCrLf & _
"Bcc recipients: " & Item.BCC & vbCrLf & _
"Are you sure you want to send this message?"
End If
Else
GoTo NonEmailError
End If
' Exit Sub
' Ignore errors for now.
On Error GoTo NonEmailError
 
' Prompt user to fill in subject
If Item.Subject = "" Then
MsgBox "You must enter a subject.", 48, "Empty Subject"
Cancel = True
GoTo NonEmailError
End If
' Exit Sub
 
' Prompt user to verify E-Mails
If MsgBox(strMsg, vbYesNo + vbQuestion _
, "Send Confirmation") = vbNo Then
Cancel = True
End If
Exit Sub

NonEmailError:
' The item being sent was not an e-mail and so don't prompt the user anything
Exit Sub
End Sub

 
If anyone can assist I'd greatly appreciate any help.
 
#1
    DiGiTAL.SkReAM

    • Total Posts : 1259
    • Scores: 7
    • Reward points : 0
    • Joined: 9/7/2005
    • Location: Clearwater, FL, USA
    • Status: offline
    Re:Outlook VB Script Wednesday, September 14, 2011 1:27 PM (permalink)
    0
    This code is to vbscript as Obama is to a President.
    Both are really close, but there are some glaring differences.

    "Would you like to touch my monkey?" - Dieter (Mike Meyers)

    "It is better to die like a tiger, than to live like a pussy."
    -Master Wong, from Balls of Fury
     
    #2
      Untalented

      • Total Posts : 4
      • Scores: 0
      • Reward points : 0
      • Joined: 9/14/2011
      • Status: offline
      Re:Outlook VB Script Thursday, September 15, 2011 12:59 AM (permalink)
      0
      I see, perhaps the For loop portion you could assist with. I believe the problem lay here as once this is added the script no longer ever functions. No errors though.
       
      #3
        DiGiTAL.SkReAM

        • Total Posts : 1259
        • Scores: 7
        • Reward points : 0
        • Joined: 9/7/2005
        • Location: Clearwater, FL, USA
        • Status: offline
        Re:Outlook VB Script Thursday, September 15, 2011 1:17 AM (permalink)
        0
        Well, for one thing, the only GoTo statement in vbscript is in error handling, like so:
        'Turn error handling on
        On Error Resume Next
        'and turn error handling off:
        On Error GoTo 0

        Instead of GoTo, try using Call.
        If a = 1 then
        Call ErrorSub1
        Else
        DoSomethingWonderful
        End If

        "Would you like to touch my monkey?" - Dieter (Mike Meyers)

        "It is better to die like a tiger, than to live like a pussy."
        -Master Wong, from Balls of Fury
         
        #4
          ebgreen

          • Total Posts : 8227
          • Scores: 98
          • Reward points : 0
          • Joined: 7/12/2005
          • Status: offline
          Re:Outlook VB Script Thursday, September 15, 2011 1:49 AM (permalink)
          0
          The code as it is posted is VBA not VBScript at all. Are you actually looking for a VBA solution or a VBScript solution?
          "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
          Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
          http://www.visualbasicscript.com/m_47117/tm.htm
           
          #5
            Untalented

            • Total Posts : 4
            • Scores: 0
            • Reward points : 0
            • Joined: 9/14/2011
            • Status: offline
            Re:Outlook VB Script Thursday, September 15, 2011 3:54 AM (permalink)
            0
            ebgreen


            The code as it is posted is VBA not VBScript at all. Are you actually looking for a VBA solution or a VBScript solution?

            VBA, definitely my bad. For some reason I wasn't differentiating the two (or thinking) when I originally posted.
             
            #6

              Online Bookmarks Sharing: Share/Bookmark

              Jump to:

              Current active users

              There are 0 members and 1 guests.

              Icon Legend and Permission

              • New Messages
              • No New Messages
              • Hot Topic w/ New Messages
              • Hot Topic w/o New Messages
              • Locked w/ New Messages
              • Locked w/o New Messages
              • Read Message
              • Post New Thread
              • Reply to message
              • Post New Poll
              • Submit Vote
              • Post reward post
              • Delete my own posts
              • Delete my own threads
              • Rate post

              2000-2012 ASPPlayground.NET Forum Version 3.9