vba - MS Outlook 2010 how to reduce picture size in attached messages -
i have on 1k emails have pictures attached large size , want reduce there size (like 1024x800 document size).
normally open message in edit mode open picture reduce size save message long process.
so looking in vba save , remove attachments email items (vba)
sub saveattachment() 'declaration dim myitems, myitem, myattachments, myattachment object dim myort string dim myolapp new outlook.application dim myolexp outlook.explorer dim myolsel outlook.selection 'ask destination folder myort = inputbox("destination", "save attachments", "c:\") on error resume next 'work on selected items set myolexp = myolapp.activeexplorer set myolsel = myolexp.selection 'for items do... each myitem in myolsel 'point on attachments set myattachments = myitem.attachments 'if there some... if myattachments.count > 0 'add remark message text myitem.body = myitem.body & vbcrlf & _ "removed attachments:" & vbcrlf 'for attachments do... = 1 myattachments.count 'save them destination myattachments(i).saveasfile myort & _ myattachments(i).displayname 'add name , destination message text myitem.body = myitem.body & _ "file: " & myort & _ myattachments(i).displayname & vbcrlf next 'for attachments do... while myattachments.count > 0 'remove (use method in outlook xp) 'myattachments.remove 1 'remove (use method in outlook 2000) myattachments(1).delete wend 'save item without attachments myitem.save end if next 'free variables set myitems = nothing set myitem = nothing set myattachments = nothing set myattachment = nothing set myolapp = nothing set myolexp = nothing set myolsel = nothing end sub
note: have keep large picture @ least month after want reduce picture sizes can not set option receiving smaller size email.
the outlook object model doesn't provide editing attachments on fly. however, workaround may use low-level property getting setting byte array represents attached file. propertyaccessor class outlook object model (see corresponding property of attachment class) can used retrieving pr_attach_data_bin property value. dasl name "http://schemas.microsoft.com/mapi/proptag/0x37010102"
.
the outlook object model allows save attached file on disk using saveasfile method of attachment class, required changes , re-attach anew using add method of attachments class.
Comments
Post a Comment