Capture "forward event" ?

Status
Not open for further replies.
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
I'd like to use VBA which triggers when "forward" is chosen. All the code I've seen is how to *initiate* a forwarding. That's not my target. Rather, I'm trying to capture when forward has just been chosen.

I may be wanting code for "OnForwarding" (a made-up word) or possibly MailItem.Forward Event
(http://msdn.microsoft.com/en-us/library/office/ff862702(v=office.15).aspx)

So I'm looking to trigger code when forwarding has just been chosen, not when "send" is hit (Application_ItemSend); maybe something like Application_ItemForward (another made up word). I'm just stressing, I'm not trying to create a forwarding as myItem.Forward might do; I'm trying to figure out how to react when the forwarding has already been initiated such as by alt-W.


(FYI my intent is to automatically and always prepend
myAttachment.DisplayName & "(size:" & Format(myAttachment.Size, "0,0") & ")"
to the mailItem's .Body when alt-W is hit (i.e., when forwarding is chosen), from
For Each myAttachment In Inspector.CurrentItem.Attachments
or such.)
 
Thank you. Sorry for delay in responding, while grateful for your fast response.

I put all three routines (with End Subs) in ThisOutlookSession, added Dims provisionally to satisfy Option Explicit, added the Word reference, and ran, but none of them fired upon reply or reply all or forward. It looks good but I put Stop in each routine and none of them are executing when I go alt-R, alt-L, alt-W.

FYI I already had
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
and that does capture when Send occurs, just to establish that I'm not so completely fouled up that I am using ThisOutlookSessionMisspelled or such.
 
it works here in outlook 2007 - but i did notice that it doesn't work with some messages. I used the macros at http://www.slipstick.com/developer/code-samples/insert-attachment-names-replying/
and copied one, renamed it
Private Sub oItem_Forward(ByVal Response As Object, Cancel As Boolean)
- changed the string to
strAtt = strAtt & "<<" & oAtt.FileName & " " & oAtt.Size / 1024 & "KB >> "

The attachment names and sizes are added to the messages when I reply, forward or reply all.
<<image001.png 7.2568359375KB >> <<May 2014 Alternative.pdf 4447.828125KB >>

Oh, if you use my code, it only gets attachments over 5KB - you will need to reduce the size if the attachments are shown as 5 KB or less in the attachment line.
 
oh, and during testing, you need to select a different message - it won't work to keep testing on one message as it uses on selection change.
 
once I remembered the need to select a different message when testing, I finally got the file size to round. :)

strAtt = strAtt & "<<" & oAtt.FileName & " " & Round(oAtt.Size / 1024, 2) & "KB >> "
 
Thank you, but every message I've tried in 2007 does not hit the code. It does hit
Private Sub Application_ItemSend
when I went alt-S on a reply, but none of the routines you mentioned fired off (I put a breakpoint or Stop statement in each).

Both changing the code sub name from Reply to Forward, and from Reply All to Forward, neither hit. :( :( :(

In case it's helpful, my references are

Visual Basic for Applications
Microsoft Outlook 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
Microsoft Word 12.0 Object Library

I do use Option Explicit, and compile is okay.
 
It's strange, 2 times out of 15, the code fired off. It worked swell when it did, but !!

The selection change is a little awkward to do so it would be great if that wasn't required. Worse than that, though, IT is not firing most of the time either though :(
 
From the few times I've got it to work, I've observed that if someone has an image as their "signature" then that is counted in the attachments collection. That is, an "inline image" is counted as an attachment (if I'm wording this correctly). Example, <<image001.png 8KB >>

Also, restarting Outlook (2007 anyway) can make it start catching the code after it "stops doing so." At some point it stops capturing the reply or forward (and for that matter, selection change from arrowing through the message list), and the only remedy seems to be to restart OL.

Suggestion for code:
strAtt = strAtt & "<<" & oAtt.FileName & " " & Format(oAtt.Size / 1024, "0") & " KB >> "
where Format command in this case produces
7 KB
rather than something like
6.715543 KB

FWIW I also preceded that with these 3 lines and a Dim for i
If Len(strAtt) < 1 Then strAtt = "Prior message attachments over 5K: "
i = Len("Prior message attachments over 5K: ")
If Len(strAtt) > i Then strAtt = strAtt & " ; "
strAtt = strAtt & "<<" & oAtt.FileName & " " & Format(oAtt.Size / 1024, "0") & " KB >> "
 
Correct on the signature images - that is why i had the original code set to skip images smaller than 5200 bytes - images in many signatures are smaller. But my test message had a 5 KB pdf and I thought it wasn't working. :)

One thing you could do is check file names from the right and skip jpg, png, or gif if under 5200 (or higher if those aren't files you are looking for).
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Capture email addresses and create a comma separated list Outlook VBA and Custom Forms 5
R Capture Sender's Display name and Address Outlook VBA and Custom Forms 3
M Using field names to capture a data element Using Outlook 0
I Capture incoming emails Outlook VBA and Custom Forms 1
A Capture network traffic in IE to file Outlook VBA and Custom Forms 5
JorgeDario How to capture and save the text, when responding a MailItem? Outlook VBA and Custom Forms 3
J VBA Form in Outlook to capture data and complile a mail Outlook VBA and Custom Forms 2
A how to capture events for next item Outlook VBA and Custom Forms 10
B Capture Inbound E-mail Subject with VBA Outlook VBA and Custom Forms 4
R How to capture a Mailitem Event Outlook VBA and Custom Forms 3
A how to capture outlook 2007 events Outlook VBA and Custom Forms 4
T Some way to capture who marks an email as read Outlook VBA and Custom Forms 1
C Event Capture - Item Context Menu (Delete). Can you hook it? Outlook VBA and Custom Forms 1
D Outlook VBA forward the selected email to the original sender’s email ID (including the email used in TO, CC Field) from the email chain Outlook VBA and Custom Forms 2
A Forward mails with "FW:" or "RE:" in title Using Outlook 2
J Outlook 365 Forward Email Subject to my inbox when new email arrive in shared inbox Using Outlook 0
L Fetch, edit and forward an email with VBA outlook Outlook VBA and Custom Forms 2
D Outlook 365 Forward Meeting Related Messages to Specific Meeting Organizer Outlook VBA and Custom Forms 0
T Customized form: The Forward option shows write layout Outlook VBA and Custom Forms 0
richardwing Auto forward email that is moves into a specific outlook folder Outlook VBA and Custom Forms 5
Z VBA Forward vs manual forward Outlook VBA and Custom Forms 2
A Outlook 2016 Macro to Reply, ReplyAll, or Forward(but with composing new email) Outlook VBA and Custom Forms 0
F Forward incoming email with 4 embedded images in the body without original sender Outlook VBA and Custom Forms 22
David McKay VBA to manually forward using odd options Outlook VBA and Custom Forms 1
S Auto forward for multiple emails Outlook VBA and Custom Forms 0
G Forward email body to other mail list directly from Exchange server Exchange Server Administration 1
D auto forward base on email address in body email Outlook VBA and Custom Forms 0
Bering Forward selected email without the original email appended Outlook VBA and Custom Forms 0
C UDFs Reply vs Forward Outlook VBA and Custom Forms 3
M In Outlook Calendar remove the buttons: 'Today' and '<' (Back a day) and '>' (Forward a day) that are below the Ribbon and above the calendar display. Using Outlook 0
J Automatically forward email and apply template Outlook VBA and Custom Forms 0
O Forward a email with modified body Automatically. Outlook VBA and Custom Forms 0
C How to rename subject line and forward the email Outlook VBA and Custom Forms 2
R Error when trying to forward current email item Outlook VBA and Custom Forms 7
M Outlook macro to automate search and forward process Outlook VBA and Custom Forms 6
G Missing forward/replied icons Using Outlook 2
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
B Automatically Forward Emails and Remove/Replace All or Part of Body Outlook VBA and Custom Forms 8
M Forward Appointment as BCC with VBScript Outlook VBA and Custom Forms 7
B Forward every other email in Outlook 2013 Outlook VBA and Custom Forms 2
D Disable or hide "reply" and "reply to all" and "forward" in email from access vba Outlook VBA and Custom Forms 1
Sabastian Samuel HOW DO I FORWARD AN EMAIL WITH MACRO using an email that in the body of another email Outlook VBA and Custom Forms 3
C Don't forward duplicate Using Outlook 0
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
A Forward Outlook Email by Filtering using Macro Rule Outlook VBA and Custom Forms 44
I change subject and forward without FW: Outlook VBA and Custom Forms 4
C VBA to Forward e-mails from certain address and between certain times Outlook VBA and Custom Forms 1
J Forward Action in Form Outlook VBA and Custom Forms 1
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
K add pdf to every reply or forward Outlook VBA and Custom Forms 1

Similar threads

Back
Top