Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Attachment Size

Status
Not open for further replies.

chugger93

Technical User
Nov 10, 2006
2
US
Ive been searching for hours... I'm trying to write a small macro or whatever to check the persons email's attachment size before it is sent. If above 1 meg or whatever, display error msg.

Nothing is out there on the internet. I found one peice of code, but it doesnt get the attachment size limit for outlook 2003.

Any ideas?
 
I don't think you can without opening the attachment's host application.

However the MailItem has a .size property.
 
Well, this doesnt work worth crap :(


Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If TypeOf Item Is Outlook.MailItem Then
Cancel = Not SendBigMail(Item)
End If
End Sub

Private Function SendBigMail(oMail As Outlook.MailItem) As Boolean
Dim lSize As Long
Const MAX_SIZE As Long = 1000
Dim bSend As Boolean

bSend = True
If oMail.Attachments.Count > 0 Then
lSize = oMail.Size
If lSize > MAX_SIZE Then
bSend = (MsgBox("Size: " & lSize & " Byte. Cancel?", vbYesNo) = vbNo)
End If
End If
SendBigMail = bSend
End Function
 
chugger93,
Just a thought, I know when I'm sending a message with an attachment I have to save the item before the size will show in the properties. I wonder if this might be the issue?

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top