PDA

View Full Version : Saving attachments greater then 200 KB



meteking
09-05-2014, 12:42 AM
Hi all,

I'm trying to save an attachment to my computer automatically from mails that i recive everday. Code that i use is below. If mail body has a image in the signature part, vba selects that image first as attechment, renames and saves it. But that file is not the one i m looking for (i need excel file). The excel files size is always greater than 200 kb so i thought if i can choose attechment greater than 200, vba can save attachment that i want. I'm using filelen but i can't show the path of (the mail contains attachment) mail. Please help me :)

Sorry for my bad english

Thx..l


Public Sub saveAttachtoDiskBEFNAT(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Users\U077689\Desktop\FHB PAY"
Dim filename As String


filename = "BEF FONLARI NAKIT AKIS.xls"


For Each objAtt In itm.Attachments


Next
If FileLen(???????) > 200 Then objAtt.SaveAsFile saveFolder & "\" & filename



End Sub

westconn1
09-05-2014, 02:35 AM
i am sure it would be easier to just check the filename of the attachments assuming only one excel workbook

For Each objAtt In itm.Attachments
if instr(objatt.filename, ".xls") > 0 then objAtt.SaveAsFile saveFolder & "\" & filename
Next

meteking
09-05-2014, 05:19 AM
i am sure it would be easier to just check the filename of the attachments assuming only one excel workbook

For Each objAtt In itm.Attachments
if instr(objatt.filename, ".xls") > 0 then objAtt.SaveAsFile saveFolder & "\" & filename
Next

It perfectly worked :yes Thxxxxxx:clap: