How to stop an email being sent

S

Steve W

I have a VB6 add-in that uses Redemption to 'unwind' emails that have
attachments that are themselves emails.

The code works like this :

oSafeMessageMail as Redemption.MessageItem
oSafeMail as Redemption.SafeMailItem
oNewEmail as Outlook.MailItem

Open email
If it has > 1 attachment Then
For each attachment
If this is an email Then
set oSafeMessageMail = attachment.EmbeddedMsg
oSafeMail.Item = oSafeMessageMail
oNewEmail = Outlook.CreateItem(olMailItem)
oSafeMail.CopyTo oNewMail
'some code here to set oNewEmail, oSafeMailItem and
oSafeMessageMail to Nothing and then re-open the
'the email, setting oNewEmail to it - this is following the
Redemption advice to as "Outlook remembers the old values of some
properties"
move oNewEmail to a specific folder
End If
Loop
End If

This all works fine, except that a copy of the new email appears in my
Outbox and will ultimately be sent when I hit Send/Receive. I understand
that this happens because the relevant flag (the MSGFLAG_UNSENT bit in
PR_MESSAGE_FLAGS property) is effectively read-only so I cannot change it's
value and Outlook thinks this is a message to send. I can get around this
because I can find the message in my Outbox and delete it (the copy in the
other folder is fine) which obviously stops it being sent.

My question is : if the user is using Outlook with Exchange Server, will I
be able to look through my Outbox before the email is sent from it ?

Any suggestions / advice would be much appreciated,

Thanks

Steve
 
K

Ken Slovak - [MVP - Outlook]

You could trap ItemAdd on the Outbox's Items collection but why not
just create the item in a different folder, like Drafts? Use the Add
method of the Items collection of the Drafts folder to create the
message in that folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm
 
S

Steve W

Thanks Ken.

I tried creating the email in a folder using the Add method (and it did
create it there), but I always get a copy in the outbox which is identical
to the first but unsent.

I'll have a look at the ItemAdd on the Outbox. Is it true to say that all
sent emails go though the Outbox ?

Steve

Ken Slovak - said:
You could trap ItemAdd on the Outbox's Items collection but why not
just create the item in a different folder, like Drafts? Use the Add
method of the Items collection of the Drafts folder to create the
message in that folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Steve W said:
I have a VB6 add-in that uses Redemption to 'unwind' emails that have
attachments that are themselves emails.

The code works like this :

oSafeMessageMail as Redemption.MessageItem
oSafeMail as Redemption.SafeMailItem
oNewEmail as Outlook.MailItem

Open email
If it has > 1 attachment Then
For each attachment
If this is an email Then
set oSafeMessageMail = attachment.EmbeddedMsg
oSafeMail.Item = oSafeMessageMail
oNewEmail = Outlook.CreateItem(olMailItem)
oSafeMail.CopyTo oNewMail
'some code here to set oNewEmail, oSafeMailItem and
oSafeMessageMail to Nothing and then re-open the
'the email, setting oNewEmail to it - this is following the
Redemption advice to as "Outlook remembers the old values of some
properties"
move oNewEmail to a specific folder
End If
Loop
End If

This all works fine, except that a copy of the new email appears in my
Outbox and will ultimately be sent when I hit Send/Receive. I understand
that this happens because the relevant flag (the MSGFLAG_UNSENT bit in
PR_MESSAGE_FLAGS property) is effectively read-only so I cannot change it's
value and Outlook thinks this is a message to send. I can get around this
because I can find the message in my Outbox and delete it (the copy in the
other folder is fine) which obviously stops it being sent.

My question is : if the user is using Outlook with Exchange Server, will I
be able to look through my Outbox before the email is sent from it ?

Any suggestions / advice would be much appreciated,

Thanks

Steve
 
S

Steve W

Early signs are good. Any new email (including replies to and forwards of
existing emails) always have '01/01/4501'.

Steve

Ken Slovak - said:
I don't see any flaws offhand but try it and see.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Steve W said:
I think I get it in the Outbox because I set the new email to a saved one
(oSafeMail.CopyTo oNewMail) and Outlook doesn't recognise that the email has
been previously sent (apparently you can't set the 'Sent' property - it's
read only). Stepping through the code it does appear that the 'SentOn'
property is set to the date on which the original email was sent, with
emails not previously sent having a date of '01/01/4501'. I'm thinking of
testing for this and basically deleting any email that comes into the Outbox
with a SentOn date.

Does that make sense ? Can you see any flaws in my (cunning ?!) plan ?

Thanks

Steve
 
E

Ettore

I have a similar problem.
I want to send a mail and I want to save, in the Sent Items folder, another
mail (different from the first one because I change the body).

At the moment I set the attribute DeleteAfterSubmit to true. Then I copy the
mail in the Sent Items Folder (changing the body) and finally I send the
mail.
It works...but the mail I saved isn't a sent mail: it is just a mail saved
(as draft) in the Sent Items folder but not sent and the sent date is setted
to none.
So I tryed to set, using CDO, the Sent and the TimeSent attribute: now the
date is setted correctly but the mail is yet shown as draft.

Can anyone help me?
Is it possible to set a draft mail as sent?

Thanks in advance.
Ettore.

Ken Slovak - said:
You could trap ItemAdd on the Outbox's Items collection but why not
just create the item in a different folder, like Drafts? Use the Add
method of the Items collection of the Drafts folder to create the
message in that folder.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Lead Author, Professional Outlook 2000 Programming, Wrox Press
Lead Author, Beginning VB 6 Application Development, Wrox Press
Attachment Options
http://www.slovaktech.com/attachmentoptions.htm
Extended Reminders
http://www.slovaktech.com/extendedreminders.htm


Steve W said:
I have a VB6 add-in that uses Redemption to 'unwind' emails that have
attachments that are themselves emails.

The code works like this :

oSafeMessageMail as Redemption.MessageItem
oSafeMail as Redemption.SafeMailItem
oNewEmail as Outlook.MailItem

Open email
If it has > 1 attachment Then
For each attachment
If this is an email Then
set oSafeMessageMail = attachment.EmbeddedMsg
oSafeMail.Item = oSafeMessageMail
oNewEmail = Outlook.CreateItem(olMailItem)
oSafeMail.CopyTo oNewMail
'some code here to set oNewEmail, oSafeMailItem and
oSafeMessageMail to Nothing and then re-open the
'the email, setting oNewEmail to it - this is following the
Redemption advice to as "Outlook remembers the old values of some
properties"
move oNewEmail to a specific folder
End If
Loop
End If

This all works fine, except that a copy of the new email appears in my
Outbox and will ultimately be sent when I hit Send/Receive. I understand
that this happens because the relevant flag (the MSGFLAG_UNSENT bit in
PR_MESSAGE_FLAGS property) is effectively read-only so I cannot change it's
value and Outlook thinks this is a message to send. I can get around this
because I can find the message in my Outbox and delete it (the copy in the
other folder is fine) which obviously stops it being sent.

My question is : if the user is using Outlook with Exchange Server, will I
be able to look through my Outbox before the email is sent from it ?

Any suggestions / advice would be much appreciated,

Thanks

Steve
 
K

Ken Slovak - [MVP - Outlook]

Setting the properties that indicate an item was sent can't be done by
the user, it's done by the mail transport. You actually have to send
the item to get the properties set correctly.
 

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