wnazzaro
04-30-2007, 10:00 AM
I want this code to check the size of an e-mail message before it sends and if the message is going to be 1MB or larger, alert the user and allow the send to be cancelled. The code below seems to work, as long as there is only one item in the collection ActiveExplorer.Selection. However if more than one message is open, the wrong message may be checked for size. I think all I need is the line of code that sets Item = Active MailItem, however I can't seem to locate the correct syntax. All help is greatly appreciated.
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim YN As Byte
Set Item = ActiveExplorer.Selection(1)
If Item.Size > 999999 Then
YN = MsgBox("The message you want to send is " & _
CStr(Item.Size) & " bytes large. Are you certain" & _
" you want to send this message", vbYesNo, "Message Size")
If YN = 6 Then
Cancel = False
Else
Cancel = True
End If
End If
End Sub
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim YN As Byte
Set Item = ActiveExplorer.Selection(1)
If Item.Size > 999999 Then
YN = MsgBox("The message you want to send is " & _
CStr(Item.Size) & " bytes large. Are you certain" & _
" you want to send this message", vbYesNo, "Message Size")
If YN = 6 Then
Cancel = False
Else
Cancel = True
End If
End If
End Sub