• Welcome to Windows10Forum.com, a free community where people just like you come together to discuss, share and learn how to use their computers. Using this forum is easy and fun. As a guest, you can browse and view all the content on the site, however, you won't be able to leave comments or create new topics unless you create a free account. 

    Click here to Register a free account now and JOIN the discussion!

Sign in to follow this  
Nualw

outlook question--compress attachments

Recommended Posts

I always need to attach some files from different folders to a email to send it to my boss. But sometimes I will find that the attachment file size is almost over the size limit. So I have to find and copy all that files to same folder and compress them as a rar file to reduce the size. Then attach the rar file to email again. It really cost too much time as I have to deal with a lot of files everyday.

I hope there is a way can easily compress the attachments as a .rar file in outlook emails directly. So when I find attachment file size is almost over the size limit, I can just use that fuction to do that in the email directly.

I have tried to find a way but failed. Is that possible?

Share this post


Link to post
Share on other sites

Hi,

There is no such fuction in outlook. but as a workaround, you can use VBA. See below:

 

Sub RarAttachments()
    Dim objMail As Outlook.MailItem
    Dim objAttachments As Outlook.attachments
    Dim objAttachment As Outlook.Attachment
    Dim objFileSystem As Object
    Dim objShell As Object
    Dim strTempFolder As Variant
    Dim strRARFile As Variant
    Dim strSourceFile As String
 
    'Save the attachments to Temporary folder
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    strTempFolder = objFileSystem.GetSpecialFolder(2).Path & "\Temp " & Format(Now, "YYYY-MM-DD hh-mm-ss")
    MkDir (strTempFolder)
 
    Set objMail = Outlook.Application.ActiveInspector.CurrentItem
    Set objAttachments = objMail.attachments
    For Each objAttachment In objAttachments
        objAttachment.SaveAsFile (strTempFolder & "\" & objAttachment.FileName)
    Next
 
    'Create a new RAR file
    strRARFile = InputBox("Specify a name for the new zip file", "Name Zip File", objMail.Subject)
    strRARFile = objFileSystem.GetSpecialFolder(2).Path & "\" & strRARFile & ".rar"
    Open strRARFile For Output As #1
    Print #1, Chr$(80) & Chr$(75) & Chr$(5) & Chr$(6) & String(18, 0)
    Close #1
 
    Set objShell = CreateObject("Shell.Application")
 
    'Add the files to the New RAR file
    strSourceFile = Dir(strTempFolder)
 
    While strSourceFile <> ""
          'Change "C:\Program Files (x86)\WinRAR\WinRAR.exe" to the location where your WinRAR is installed
          objShell.Run Chr(34) & "C:\Program Files (x86)\WinRAR\WinRAR.exe" & Chr(34) & " a -r" & Chr(34) & strRARFile & Chr(34) & " " & Chr(34) & strSourceFile & Chr(34)
          strSourceFile = Dir
    Wend
 
    'Delete all the attachments
    Set objAttachments = objMail.attachments
 
    While objAttachments.Count > 0
          objAttachments.Item(1).Delete
    Wend
 
    'Add the new RAR file to the current email
    objMail.attachments.Add strRARFile
 
    'Prompt you
    MsgBox "Complete!", vbExclamation
End Sub

And here is the article with this codes. You can find more details at

 

How to Quickly Compress All Attachments into a RAR File in Your Outlook Email

 

Hope it helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Who's Online   0 Members, 0 Anonymous, 34 Guests (See full list)

    There are no registered users currently online