How to prevent that Outlook is sending before my add-in is finished?

Status
Not open for further replies.
K

Kukulkan

Hi,

I made an Outlook AddIn (OL2003 and OL2007) by using VB6 and

Redemption Objects. I need to manipulate the message before sending

(change Body, remove and add attachments). In most cases this works

fine, but in some rare cases there seem to occur problems. It looks

like OL is sending the message before my add-in is finished. This is

mainly observed on OL that is connected to an Exchange server.

In my code I need to call Mailitem.Save a few times. For example,

after removing attachments and before adding a new one (without this,

adding attachments will fail). I suppose that OL uses exactly this

moment to send the message. This results in messages that do not

contain the attachment that I like to add later.

Is there a way to prevent sending messages for a while? I want to be

shure that the message will get only sent after I finished my job? Any

idea?

Thanks,

Kukulkan
 
K

Ken Slovak - [MVP - Outlook]

What event are you using? I've never had any sends go out without my

allowing it when I've handled either the Send() event for an item or the

Application.ItemSend() event. It doesn't matter if Exchange is involved, the

first thing that will happen after an item is sent is the firing of the

Send() event for that item.

"Kukulkan" <regify@googlemail.com> wrote in message

news:f696cb7f-dd1a-4a54-82af-eaee7473f39d@c16g2000yqd.googlegroups.com...
> Hi,

> I made an Outlook AddIn (OL2003 and OL2007) by using VB6 and
> Redemption Objects. I need to manipulate the message before sending
> (change Body, remove and add attachments). In most cases this works
> fine, but in some rare cases there seem to occur problems. It looks
> like OL is sending the message before my add-in is finished. This is
> mainly observed on OL that is connected to an Exchange server.

> In my code I need to call Mailitem.Save a few times. For example,
> after removing attachments and before adding a new one (without this,
> adding attachments will fail). I suppose that OL uses exactly this
> moment to send the message. This results in messages that do not
> contain the attachment that I like to add later.

> Is there a way to prevent sending messages for a while? I want to be
> shure that the message will get only sent after I finished my job? Any
> idea?

> Thanks,

> Kukulkan
 
K

Kukulkan

Re: How to prevent that Outlook is sending before my add-in isfinished?

Hi Ken,


> What event are you using? I've never had any sends go out without my
> allowing it when I've handled either the Send() event for an item or the
> Application.ItemSend() event. It doesn't matter if Exchange is involved, the
> first thing that will happen after an item is sent is the firing of the
> Send() event for that item.


I capture the send-event of the mailitem. Inside, I call my function

to reconvert the e-mail before sending. I think, the mailitem is

already marked for delivery in this moment. And outlook does not wait

until the Sent() event returns and try's to send in the meanwhile

(possibly in the moment I call Item.save).

While processing, I call an external compression utility using Shell()

command. To wait for the end of this tool, I use

OpenProcess(PROCESS_QUERY_INFORMATION + SYNCHRONIZE, 0, TaskID) and

GetExitCodeProcess() in a loop with many DoEvents calls. May this be

part of the problem?

I wrapped the send-item event to capture it. The Cancel-Property is

wrapped, too. Only some customers are affected. On others it runs

perfectly. Is there a way to prevent outlook from sending/receiving

while I'm processing the mail?

Regards,

Kukulkan
 
K

Kukulkan

Re: How to prevent that Outlook is sending before my add-in isfinished?

Hi Ken,

Thank you for your help.


> My guess is that your code is hitting an unexpected error in those cases
> where you have problems and is aborting your event handler or bypassing
> parts of it.


I used the debugger to step through all parts. Every involved routine

has an on error goto statement with an error-dialog. The complete

problem is, that I sometimes having different weird behaviours in

exchange environment (only by my customers, but never here):

Sometimes, the e-mail gets received multiple times by the recipients.

They are all identical. In my routines, I manipulate one(!) e-mail,

and in rare cases the recipient receives up to 5 copies (sometimes

only 3 or 2. That changes random). I do not change any recipients in

the e-mail. In the sent-items folder of the sender, there is only one

item! In my inbox, there are sometimes three absolute identical mails.

Sometimes, the e-mail comes without attachment. I definitely add an

attachment to the mail! In the sent-items folder of the sender, the e-

mail has the attachment. In my inbox, there is no attachment.

Something really strage is going on here...

I will try to find out more. Maybe one of my customers is willing to

let me do some debugging...

Kukulkan
 
K

Kukulkan

Re: How to prevent that Outlook is sending before my add-in isfinished?

I have additional information:

I checked the behaviour with one of my customers. This is what we

found:

An e-mail, TO: Recipient1 CC: Recipient2 should be processed.

- processing occured with no error-message (changed Body and

Attachments)

- Recipient1 received the e-mail two times incl. attachment

- Recipient2 received the e-mail without attachment (one times)

- in sent-items folder of the sender, the e-mail is found one times

without(!) attachment

This is strange. The same mail arrived two times at Recipient1 -

including the attachment!

In sent-items folder, the attachment is missing!

Any idea? On most customers, no problems occur. Maybe a problem with

CC:? Is there something to take care about? Any idea?

Thank you,

Kukulkan
 
K

Ken Slovak - [MVP - Outlook]

This is only a guess, and you need to find what's different about systems

where the problem occurs and where it doesn't, but my guess is an anti-virus

addin that scans outgoing and incoming emails. That's almost always a bad

idea and can cause problems like the ones you're seeing. Multiple sends,

sometimes hundreds of them, items lost in space or a black hole and various

other problems are all common when incoming/outgoing emails are scanned. See

if that's the possible cause of the problem.

"Kukulkan" <regify@googlemail.com> wrote in message

news:49cc75fb-baf1-4159-b8ce-f7b4c7599d3a@b30g2000yqd.googlegroups.com...
> I have additional information:

> I checked the behaviour with one of my customers. This is what we
> found:

> An e-mail, TO: Recipient1 CC: Recipient2 should be processed.
> - processing occured with no error-message (changed Body and
> Attachments)
> - Recipient1 received the e-mail two times incl. attachment
> - Recipient2 received the e-mail without attachment (one times)
> - in sent-items folder of the sender, the e-mail is found one times
> without(!) attachment

> This is strange. The same mail arrived two times at Recipient1 -
> including the attachment!
> In sent-items folder, the attachment is missing!

> Any idea? On most customers, no problems occur. Maybe a problem with
> CC:? Is there something to take care about? Any idea?

> Thank you,

> Kukulkan
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
I How to prevent exchange email account from sending emails in Outlook Using Outlook 4
C Prevent Outlook from sending an email with a blank Subject Line Outlook VBA and Custom Forms 3
P Prevent Outlook 2016 from using DASL filter Using Outlook 4
oj43085 Prevent Outlook from blocking image from a single source Using Outlook 4
D Prevent Outlook from resolving incomplete contact when clicking send Using Outlook 2
D Prevent popup of "Do you want to save changes?" when closing after opening an appointment to view Outlook VBA and Custom Forms 2
O How to prevent CC from showing when creating a new mail? Using Outlook 1
A Prevent connection to Public Folders on Exchange? Exchange Server Administration 3
L OL 2016 contact: is there a way to prevent an admin from mistakenly deleting a contact? Using Outlook 1
D Multiple mailboxes, 1 certificate. How to prevent message "Invalid Certificate" Using Outlook 0
S How to prevent addins Using Outlook 0
makinmyway How Prevent Re-Formatting of Contact Notes Field When Syncing Using Outlook 10
Diane Poremsky Prevent Users From Choosing Stationery Using Outlook 0
evdbogaard How to prevent extra line feeds in replies Using Outlook 3
oliv- Prevent copying shared contacts Outlook VBA and Custom Forms 5
K Prevent meeting requests being sent from a shared calendar in a group mailbox Using Outlook 1
N Prevent reminder dismisal in shared calendar Using Outlook 1
C Security Question - How to prevent users exporting .iaf files Using Outlook 5
B Item_Write = False don't prevent custom form from closing Using Outlook 1
T WAB editing: To help prevent malicious code from running.......... Using Outlook 18
N Allow Another User to Send on Behalf of But Prevent Access to Inbox Using Outlook 4
R Exchange 2010 archive-prevent users moving items direct to archive Exchange Server Administration 1
M Links prevent sending email Using Outlook 3
K Prevent sending Excel files as attachements Outlook VBA and Custom Forms 1
G To Prevent Malicious Code from running, one or more objects in thi BCM (Business Contact Manager) 2
S To help prevent malicious code from running, one or more objects in this form were not loaded. For m Outlook VBA and Custom Forms 1
A Script to either modify "from" address or prevent a reply being se Outlook VBA and Custom Forms 2
J prevent user from installing wrong version of add-in Outlook VBA and Custom Forms 2
Z Prevent Changes to Custom Form Outlook VBA and Custom Forms 1
N Can't create NEW GROUP and add/remove a member from existing Group in Outlook Using Outlook 1
P Outlook tasks keeps changing (updating) dates that I type Using Outlook 2
M I cant send emails via Outlook in my W10 PC. Using Outlook 3
A Outlook Reminders not populating for certain events Using Outlook 2
O Moving "tasks" to inbox in Outlook 2016 Using Outlook 1
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
e_a_g_l_e_p_i Can emails from Gmail be deleted when they are downloaded to Outlook 2010 Using Outlook 1
cbufacchi Outlook 365 Populate custom Outlook Appoint form Outlook VBA and Custom Forms 2
Z Remove GMAIL IMAP account from Outlook 2016 Using Outlook 2
D Wrong email address in Outlook 2003 "From" tab in new outgoing emails Using Outlook 4
B Outlook 365 Populate Outlook Task UDFs from a UDF text string Outlook VBA and Custom Forms 2
witzker Outlook 2019 Pls. add a Prefix for OUTLOOK 2019 here Using Outlook 1
H Outlook 2019 intermittent search results Using Outlook 0
hstein POP3 latest Outlook Using Outlook 0
V Outlook 2003 and Windows 11 Using Outlook 4
J How to import many msg into different public folders in Outlook Outlook VBA and Custom Forms 7
I Outlook for Mac 2019 using on desktop and laptop IMAP on both need help with folders Using Outlook 1
A Reminder duplication Outlook and Outlook.com Using Outlook.com accounts in Outlook 5
F Moving Outlook to new PC Using Outlook 0
mll persistently customise columns in outlook advanced search Using Outlook 3
Ken Pascoe Outlook Categories Quick List Using Outlook 0

Similar threads

Top