CreateItemFromTemplate without signature?

A

Alun Jones

I have a script in VBScript (not VBA) that uses the Outlook.Application
object to create and send an email. The script uses CreateItemFromTemplate
to create the MailItem object, and when it does so, if the user running the
script has enabled the "Signature for new messages" option in Mail Format,
that signature is appended to my template. I'd like for this to not happen -
how can I prevent the signature from being added by CreateItemFromTemplate?

Thanks,

Alun.
~~~~
 
K

Ken Slovak - [MVP - Outlook]

If the user's default is to add a signature then that's what's going to
happen. You could design a custom template, save it as a OFT file and then
open that from the file system using CreateItemFromTemplate. You could also
just clear out the signature once the item has opened in the first Activate
event of the newly opened Inspector. Just set .Body to null string to clear
it out.
 
A

Alun Jones

What's rather strange about this is that the signature only appears if I
choose to .Display the message. If I simply ".Close olSave", or ".Send", the
signature is _not_ added to the message. Sorry if this sounds like new
information, but I only discovered this fact yesterday.

For now, I'm telling the script user that this is what it will do from now
on - simply save the message in her drafts folder so that she can view it
herself and correct the recipients prior to sending. What I'd like to do is
be able to display it without getting the signature added.

There are two routes I'm planning on going:

1. Save the message to Drafts, then open it again and Display it (not sure
how to keep a reference to the message so I can open it again - maybe I just
need to RTFM enough to find this out)

2. Disable the signature before .Display is called, then re-enable it
afterwards. Again, not sure how to do that programmatically.

Thanks for your help, Ken.

Alun.
~~~~
 
K

Ken Slovak - [MVP - Outlook]

Signature disabling on the fly isn't something I'd want to try to code. It's
not something that's exposed and methods might vary depending on whether or
not WordMail is being used or the Outlook editor. What I would do is simply
trap the first Activate event for the new Inspector (from the NewInspector
event in the Inspectors collection) and wipe out the signature. Of course
that could present problems with replies/forwards since they'd include text
from previous messages.

You could trap the ItemAdd event for the Items collection of the Drafts
folder to know when an item was added to Drafts. You couldn't rely on
EntryID being the same when that happened, it might but might not depending
on which type of store you were working against (PST or Exchange mailbox).
 
A

Alun Jones

Yeah, that's why I went with simply closing the message without displaying
it, then opening it again by finding it in the Folder.Items object by its
subject, before displaying it to the user. Not completely reliable, perhaps,
if there's another message with the same subject, but for the application in
question, a daily report, it's not likely to be the case that the Drafts
folder contains two such messages.

Thanks for your help, Ken.

Alun.
~~~~
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top