I receive lots of e-mails with attachments, I need to forward these e-mails on but before I do so, I need to remove the attachment (there is usually only one) and below the body of the e-mail where the From, Sent, To and subject I need to enter a message which includes the name of the file removed. Something like "******* testfile1.xls removed *********". Currently I'm doing this manually but the process takes ages especially if the file names are long,
Despite searching many posts I cannot find anything that I can use, can anyone help?
i have a lot of samples that get you close, put them together and you've got a macro that works... I'm assuming you don't need to do this for all forwards, just specific ones...
This macro shows how to write the attachment name to the body: Copy attachment names when replying since you are going to manually choose to forward, you just need the code that does this, not the entire macro. That would be everything between Private Sub oItem_Reply(ByVal Response As Object, Cancel As Boolean) and End sub.
Change the name and add a dim
Public Sub RemoveForward()
Dim oItem As MailItem
after the dim's add
Set oItem = Application.ActiveExplorer.Selection.item(1)
Will it be the only attachment? if so, remove the if/end if lines otherwise change the for each attachment to look for the extension. if it's always only one attachment, remove strAtt & - change the text formatting as needed.
For Each oAtt In oItem.Attachments
If right(oAtt.filename, 4) = "xlxs" Then
strAtt = strAtt & "<<" & oAtt.FileName & ">> "
Change reply in Set oResponse = oItem.Reply to olForward.
Add this before the set oitem = nothing to delete the attachment
For Each oAtt In oResponse.Attachments