vb.net Outlook 2007 onChange event in email

diana
3StarLounger
Posts: 279
Joined: 01 Jun 2010, 00:27

vb.net Outlook 2007 onChange event in email

Post by diana »

Is there sample code to check if anything has changed in an email.

The scenario is:
New email, or existing email forward or reply
users make edits & type text
A Microsoft flag is set something similar to the old defunct ‘IsDocumentDirty' property
The emails are then saved in Draft folders

Then sse the condition/flag to perform other code

And are there known problems with using this event/code?

Many thanks

dd

User avatar
HansV
Administrator
Posts: 78530
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: vb.net Outlook 2007 onChange event in email

Post by HansV »

When exactly do you want the code to run? A new e-mail or a reply will ALWAYS be changed...
Best wishes,
Hans

diana
3StarLounger
Posts: 279
Joined: 01 Jun 2010, 00:27

Re: vb.net Outlook 2007 onChange event in email

Post by diana »

hi Hans


The code does the following:
On a email, check a custom workgroup button is enabled
Add custom templates with custom heading styles available in email by copying and making available in users profile
Set shortcut keys to the heading styles :Heading 1 – 3 and normal

User workflow:
A new email is created, or Reply or Reply To All is pressed.
a ‘Blank ‘ email is created.
No text edits are made ie no text is typed in the fields or body of the email
The email is closed
The standard Microsoft default prompt displays ‘Do you want to save Changes Yes/No’
This causes user confusion as they haven’t made edits however behind the scenes the code has made changes.

The workaround someone’s applied to hide the Microsoft dialog is is the following switch

‘Fix the prompt when new email close without making change
document.Saved = True


However the result is ‘missing edits/text in emails’, as users report they are typing emails and their edits aren’t being saved.

My feeling is a function must exist to determine if actual text has been typed in the fields of body of the email. To make the above code more accurate


dd

User avatar
HansV
Administrator
Posts: 78530
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: vb.net Outlook 2007 onChange event in email

Post by HansV »

For a new e-mail, you could check whether the Body property is not empty:

Code: Select all

    If itm.Body = "" Then
        ' message is still empty
        ...
    Else
        ' something has been entered
        ...
    End If
But I have no idea how to check whether a reply or forwarded message has been modified.
Best wishes,
Hans

diana
3StarLounger
Posts: 279
Joined: 01 Jun 2010, 00:27

Re: vb.net Outlook 2007 onChange event in email

Post by diana »

Many thanks Hans

Yes your right

Yes at this stage I dont know the correct syntax for outlook either.

Thank you again

dd