Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How do I delete draft emails?

157 views
Skip to first unread message

John Svercek

unread,
Mar 24, 2006, 3:08:32 AM3/24/06
to
I have an Outlook Addin that creates buttons on the email form. The buttons
add information to the email. I am using Redemption to allow me to include a
logo file without showing it as an attachment. In order to use Redemption I
must Save my email first. This puts a copy in the Draft folder. If the email
is sent, the draft is automatically deleted. If the email is cancelled, the
draft remains, even if I respond No to saving a copy of the email.

How do I get rid of the draft before the question is displayed (so Outlook
will save a copy if the user answers Yes).
--
John Svercek

Ken Slovak - [MVP - Outlook]

unread,
Mar 24, 2006, 10:10:04 AM3/24/06
to
Assuming you have a reference to the EntryID of the item once it's saved in
Drafts you certainly can delete it that way using
RDOSession.GetMessageFromID or if not using the RDO objects from
MAPIUtils.GetItemFromID or .GetItemFromIDEX.

If you wanted to force the Inspector to close without saving or prompted you
could use the item's or Inspector's Close methods and one of the close enum
members: olDiscard, olPromptForSave or olSave.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"John Svercek" <JohnS...@discussions.microsoft.com> wrote in message
news:63ADDEC3-4C61-4150...@microsoft.com...

John Svercek

unread,
Apr 2, 2006, 8:25:02 PM4/2/06
to
Ken, let's see if I can do a better job of explaining my problem.

When a button is clicked I create a mailitem from the inspector. Like so

'we are in the mail so add the logo as attachment and logo & info to body
Set MyMailItem = CreateObject("Redemption.SafeMailItem")
Set MyOMailItem = m_oApp.ActiveInspector.CurrentItem
MyOMailItem.Save
MyMailItem.Item = MyOMailItem

The MyOMailItem.Save command has saved the mailitem to the Drafts folder.

Following the above code, I add information to the body. If the mail is
sent, the copy in the Drafts folder gets automatically deleted.

The problem arises if the mail item is closed (user clicks Close control).
At that time the user is asked if they want to save changes. If they say No,
the window is closed but the item remains in the Draft folder.

If I programatically delete the item in the Close event then the user is
never asked if they want to save a copy, which they may.

So, how can I delete the item if the user does not want it but leave it if
they do?

--
John Svercek

Ken Slovak - [MVP - Outlook]

unread,
Apr 3, 2006, 10:10:49 AM4/3/06
to
You could check in the Close event for the Inspector and/or MailItem if
.Saved = True. That would tell you if the user had saved the item.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"John Svercek" <JohnS...@discussions.microsoft.com> wrote in message

news:37E96071-7A27-47F8...@microsoft.com...

John Svercek

unread,
Apr 3, 2006, 10:50:03 AM4/3/06
to
Problem is .Saved = True after I programatically save the item. Even if the
user selects No to the Save Changes question, the .Saved value is True.
Therefore I cannot tell if the user opted to save or delete, and I cannot
safely delete the draft item.

Since the .Saved parameter is readonly I cannot change it after I Save the
item.

--
John Svercek


"Ken Slovak - [MVP - Outlook]" wrote:

> You could check in the Close event for the Inspector and/or MailItem if

> ..Saved = True. That would tell you if the user had saved the item.

Ken Slovak - [MVP - Outlook]

unread,
Apr 3, 2006, 4:19:22 PM4/3/06
to
See if things work if you omit the line: MyOMailItem.Save

If you don't need that then the item would only be saved if your user
specifically saved it.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"John Svercek" <JohnS...@discussions.microsoft.com> wrote in message

news:474C4B87-71E2-4B3F...@microsoft.com...

John Svercek

unread,
Apr 3, 2006, 6:24:02 PM4/3/06
to
The problem is the SafeMailItem (MyMailItem) does not pick up all the
information from the MailItem (MyOMailItem) if the MailItem is not saved
first. Most notibly the Body and HTMLBody information is not copied.

Apparently this information is not available to Redemption unless the Save
is done first.

I could possibly work with the MyMailItem.Item.Body & .HTMLBody but I am not
sure of all the implications. I may try that for the next release if I cannot
find another way to do it.

--
John Svercek


"Ken Slovak - [MVP - Outlook]" wrote:

Ken Slovak - [MVP - Outlook]

unread,
Apr 4, 2006, 11:35:17 AM4/4/06
to
Sorry, that's about all I can think of. It's a bit of a Catch-22 situation I
know.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"John Svercek" <JohnS...@discussions.microsoft.com> wrote in message

news:0F4C2D87-43B8-4EA2...@microsoft.com...

Ken Slovak - [MVP - Outlook]

unread,
Apr 5, 2006, 8:55:35 AM4/5/06
to
I did have another thought on this.

Trap the Item.Write event. That would fire whenever the item was saved. You
know when you're saving it in code, any other firing of that event would be
the user's doing.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Ken Slovak - [MVP - Outlook]" <kens...@mvps.org> wrote in message
news:e%235sV2$VGHA...@TK2MSFTNGP12.phx.gbl...

0 new messages