Capture "forward event" ?

Status
Not open for further replies.
Outlook version
Outlook 2007
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.)
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Outlook version
Outlook 2007
Email Account
Exchange Server
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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 >> "
 
Outlook version
Outlook 2007
Email Account
Exchange Server
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.
 
Outlook version
Outlook 2007
Email Account
Exchange Server
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 :(
 
Outlook version
Outlook 2007
Email Account
Exchange Server
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 >> "
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
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.
Thread starter Similar threads Forum Replies Date
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
C How to capture incoming email subject to use in an auto reply Using Outlook 1
K Export of email does not capture all email Using Outlook 5
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
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
Brostin Forward a mail to the address listed in the email text Outlook VBA and Custom Forms 1
N Going Forward: Using Outlook 2016 for RSS Feeds Using Outlook 2
J Forward Message after editing attachments and include edited attachments Using Outlook 5
R changing FW: on forward Outlook VBA and Custom Forms 3
Z Auto Forward Using Outlook 4
N Outlook script to forward emails based on senders' address Outlook VBA and Custom Forms 2
S Merge Emails with attachments with inbox rule to forward Using Outlook 5
B Auto Save of Attachments from Multiple Emails and forward attachments to user group Outlook VBA and Custom Forms 1
A Creating an outlook rule to forward an email with a specific message Using Outlook 1
D Forward message to address from subject Outlook VBA and Custom Forms 1
D How to forward each email x minutes after it arrives in inbox and hasn't been moved or deleted? Using Outlook 1
W Macro to forward email Outlook VBA and Custom Forms 2
J How to change From then forward message Outlook VBA and Custom Forms 1
S Reply & Forward Date in original message incorrect Using Outlook 2
Diane Poremsky Forward Messages that were not Replied To New Slipstick.com Articles 0
mikecox Forward email to another address; not with Rules Using Outlook 3
Similar threads


















































Top