Saving an attachment - outbox and sent mail conflicts

Status
Not open for further replies.
M

MikeA

I'm trying to figure out code to save an attachment from mail that was "just

sent" not even a second after the Sent Mail is clicked.

I can't seem to do it. The code checks the outbox and sent mail and using

loOutBox.items.GetLast() and it just keeps sending the mail that was sent

"right before" the last mail was sent. It's as if Outlook is in the process

of transferring the Email sent from the outbox to the Sent Mail so it seems

to always grab the mail prior to the one that was sent.

Any ideas?

Thanks,

Mike
 
I meant to say I'm trying to save the entire mail that was sent (as an msg

file) not the attachment.

Mike

"MikeA" <appell@appellsoftware.com> wrote in message

news:uW6aE6aCKHA.4316@TK2MSFTNGP04.phx.gbl...
> I'm trying to figure out code to save an attachment from mail that was
> "just sent" not even a second after the Sent Mail is clicked.

> I can't seem to do it. The code checks the outbox and sent mail and using
> loOutBox.items.GetLast() and it just keeps sending the mail that was sent
> "right before" the last mail was sent. It's as if Outlook is in the
> process of transferring the Email sent from the outbox to the Sent Mail so
> it seems to always grab the mail prior to the one that was sent.

> Any ideas?

> Thanks,
> Mike

>
 
Re: Save Last Email Sent To MSG File

I'm trying to figure out code to save the last Email that was sent to an

msg file.

loOutBox.items.GetLast() does not seem to work and all too often gets the

Email sent prior to the very last one sent.

Any ideas?

Thanks,

Mike
 
Re: Save Last Email Sent To MSG File

Problem solved - as long as I check both the outbox and SentMail then

GetLast will work.

Mike

"MikeA" <appell@appellsoftware.com> wrote in message

news:%234E8utbCKHA.3368@TK2MSFTNGP02.phx.gbl...
> I'm trying to figure out code to save the last Email that was sent to an
> msg file.

> loOutBox.items.GetLast() does not seem to work and all too often gets the
> Email sent prior to the very last one sent.

> Any ideas?

> Thanks,
> Mike

>
 
Re: Save Last Email Sent To MSG File

You shouldn't be checking Outbox, code tickling of the item there will

interrupt and cancel the send.

What you should be doing is handling the ItemAdd() event of the Items

collection of the Sent Items folder. That will tell you exactly what item

was added to Sent Items and you don't have to fool around with GetLast() and

which item it will return.

"MikeA" <appell@appellsoftware.com> wrote in message

news:e8gLt8bCKHA.3708@TK2MSFTNGP02.phx.gbl...
> Problem solved - as long as I check both the outbox and SentMail then
> GetLast will work.

> Mike

> "MikeA" <appell@appellsoftware.com> wrote in message
> news:%234E8utbCKHA.3368@TK2MSFTNGP02.phx.gbl...
> > I'm trying to figure out code to save the last Email that was sent to an
> > msg file.
>

>> loOutBox.items.GetLast() does not seem to work and all too often gets
> > the Email sent prior to the very last one sent.
>

>> Any ideas?
>

>> Thanks,
> > Mike
>

>>


>
 
Re: Save Last Email Sent To MSG File

Can you provide some sample code on how to utilize the ItemAdd so as to save

the last item sent?

Thanks,

Mike
<kenslovak@mvps.org> wrote in message

news:eBPv%23mgCKHA.528@TK2MSFTNGP03.phx.gbl...
> You shouldn't be checking Outbox, code tickling of the item there will
> interrupt and cancel the send.

> What you should be doing is handling the ItemAdd() event of the Items
> collection of the Sent Items folder. That will tell you exactly what item
> was added to Sent Items and you don't have to fool around with GetLast()
> and which item it will return.

> >

>

> "MikeA" <appell@appellsoftware.com> wrote in message
> news:e8gLt8bCKHA.3708@TK2MSFTNGP02.phx.gbl...
> > Problem solved - as long as I check both the outbox and SentMail then
> > GetLast will work.
>

>> Mike
>

>> "MikeA" <appell@appellsoftware.com> wrote in message
> > news:%234E8utbCKHA.3368@TK2MSFTNGP02.phx.gbl...
> >> I'm trying to figure out code to save the last Email that was sent to an
> >> msg file.
> >
>>> loOutBox.items.GetLast() does not seem to work and all too often gets
> >> the Email sent prior to the very last one sent.
> >
>>> Any ideas?
> >
>>> Thanks,
> >> Mike
> >
>>>

>

>>

>
 
Re: Save Last Email Sent To MSG File

Just to clarify - A program runs right after they click the Send button from

their Email but the program is not script in the Outlook Email. A separate

program is launched and I can't seem to figure out how to get the last Email

sent so that I can save it. As it turns out, trying to get info first from

the Outbox does not work either. Still, all to often getlast is grabbing

the second to the last Email that was sent.

Mike

"MikeA" <appell@appellsoftware.com> wrote in message

news:ub$Ts3pCKHA.3800@TK2MSFTNGP04.phx.gbl...
> Can you provide some sample code on how to utilize the ItemAdd so as to
> save the last item sent?

> Thanks,
> Mike

> " - " <kenslovak@mvps.org> wrote in message
> news:eBPv%23mgCKHA.528@TK2MSFTNGP03.phx.gbl...
> > You shouldn't be checking Outbox, code tickling of the item there will
> > interrupt and cancel the send.
>

>> What you should be doing is handling the ItemAdd() event of the Items
> > collection of the Sent Items folder. That will tell you exactly what item
> > was added to Sent Items and you don't have to fool around with GetLast()
> > and which item it will return.
>

>> > >

> >

>

>
>
>
>
>
>> "MikeA" <appell@appellsoftware.com> wrote in message
> > news:e8gLt8bCKHA.3708@TK2MSFTNGP02.phx.gbl...
> >> Problem solved - as long as I check both the outbox and SentMail then
> >> GetLast will work.
> >
>>> Mike
> >
>>> "MikeA" <appell@appellsoftware.com> wrote in message
> >> news:%234E8utbCKHA.3368@TK2MSFTNGP02.phx.gbl...
> >>> I'm trying to figure out code to save the last Email that was sent to
> >>> an msg file.
> >>
>>>> loOutBox.items.GetLast() does not seem to work and all too often gets
> >>> the Email sent prior to the very last one sent.
> >>
>>>> Any ideas?
> >>
>>>> Thanks,
> >>> Mike
> >>
>>>
>>
>>>

> >


>
 
Re: Save Last Email Sent To MSG File

I'm not sure what you're saying: "A program runs right after they click the

Send button from

their Email but the program is not script in the Outlook Email.". What does

that mean?

If a program is already running, either a COM addin or a standalone program,

it can subscribe to the ItemAdd() event on the Items collection of Sent

Items. You can see an ItemAdd() handler for Inbox at www.outlookcode.com by

searching for "zaphtml".

If a program is started after the item is sent and after the item has

already been added to Sent Items then an ItemAdd() handler is useless to

you. The item will already have been added by the time the program runs.

"MikeA" <appell@appellsoftware.com> wrote in message

news:eYI%23ULqCKHA.3732@TK2MSFTNGP02.phx.gbl...
> Just to clarify - A program runs right after they click the Send button
> from their Email but the program is not script in the Outlook Email. A
> separate program is launched and I can't seem to figure out how to get the
> last Email sent so that I can save it. As it turns out, trying to get
> info first from the Outbox does not work either. Still, all to often
> getlast is grabbing the second to the last Email that was sent.

> Mike

> "MikeA" <appell@appellsoftware.com> wrote in message
> news:ub$Ts3pCKHA.3800@TK2MSFTNGP04.phx.gbl...
> > Can you provide some sample code on how to utilize the ItemAdd so as to
> > save the last item sent?
>

>> Thanks,
> > Mike
 
Re: Save Last Email Sent To MSG File

There is script in the Email being sent that runs the program. I would have

thought that getlist would work but it just does not always seem to get the

latest Email.

Mike
<kenslovak@mvps.org> wrote in message

news:OiI38ZtCKHA.3800@TK2MSFTNGP04.phx.gbl...
> I'm not sure what you're saying: "A program runs right after they click
> the Send button from
> their Email but the program is not script in the Outlook Email.". What
> does that mean?

> If a program is already running, either a COM addin or a standalone
> program, it can subscribe to the ItemAdd() event on the Items collection
> of Sent Items. You can see an ItemAdd() handler for Inbox at
> www.outlookcode.com by searching for "zaphtml".

> If a program is started after the item is sent and after the item has
> already been added to Sent Items then an ItemAdd() handler is useless to
> you. The item will already have been added by the time the program runs.

> >

>

> "MikeA" <appell@appellsoftware.com> wrote in message
> news:eYI%23ULqCKHA.3732@TK2MSFTNGP02.phx.gbl...
> > Just to clarify - A program runs right after they click the Send button
> > from their Email but the program is not script in the Outlook Email. A
> > separate program is launched and I can't seem to figure out how to get
> > the last Email sent so that I can save it. As it turns out, trying to
> > get info first from the Outbox does not work either. Still, all to often
> > getlast is grabbing the second to the last Email that was sent.
>

>> Mike
>

>
>> "MikeA" <appell@appellsoftware.com> wrote in message
> > news:ub$Ts3pCKHA.3800@TK2MSFTNGP04.phx.gbl...
> >> Can you provide some sample code on how to utilize the ItemAdd so as to
> >> save the last item sent?
> >
>>> Thanks,
> >> Mike

>
 
Re: Save Last Email Sent To MSG File

I still don't understand.

You say now the script is in the email but before you said the script was

not in the email. "A program runs right after they click the Send button

from their Email but the program is not script in the Outlook Email."

What is that program and where is it? Is this an Outlook custom form? What

is "getlist"?

To handle the ItemAdd() event for Sent Items you will either need a COM

addin, a standalone program started before the email is sent or Outlook VBA

code. Form code cannot handle any events outside the actual form.

"MikeA" <appell@appellsoftware.com> wrote in message

news:evipKZvCKHA.1380@TK2MSFTNGP02.phx.gbl...
> There is script in the Email being sent that runs the program. I would
> have thought that getlist would work but it just does not always seem to
> get the latest Email.

> Mike
 
Re: Save Last Email Sent To MSG File

I think I have resolved the problem. If I use an API Sleep(8000) in my

program it seems to work.

Yes, I have an outlook custom form that runs the program in the custom

form's Item_Send event. Then I want the program to save the form. It now

seems to be working when I issue the Sleep(8000). It seems that it needs a

slight delay from the Item_send() event and when the program is launched so

that Outlook and put the Email in the Outbox and/or sent mail.

Thanks again for all your help.

Mike
<kenslovak@mvps.org> wrote in message

news:OxNHwhvCKHA.5956@TK2MSFTNGP03.phx.gbl...
> I still don't understand.

> You say now the script is in the email but before you said the script was
> not in the email. "A program runs right after they click the Send button
> from their Email but the program is not script in the Outlook Email."

> What is that program and where is it? Is this an Outlook custom form? What
> is "getlist"?

> To handle the ItemAdd() event for Sent Items you will either need a COM
> addin, a standalone program started before the email is sent or Outlook
> VBA code. Form code cannot handle any events outside the actual form.

> >

>

> "MikeA" <appell@appellsoftware.com> wrote in message
> news:evipKZvCKHA.1380@TK2MSFTNGP02.phx.gbl...
> > There is script in the Email being sent that runs the program. I would
> > have thought that getlist would work but it just does not always seem to
> > get the latest Email.
>

>> Mike

>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
V Saving attachment from outlook in My Documents Outlook VBA and Custom Forms 14
K Copy Subject Line When Saving Attachment Outlook VBA and Custom Forms 2
N Saving attachment from shared mailbox Outlook VBA and Custom Forms 1
Rupert Dragwater Background colors not saving in Outlook 365 Using Outlook 15
R Saving Emails and Attachments as .msg file Using Outlook 3
CWM550 Saving Data: Don't check certain folders Using Outlook 2
M Saving emails using Visual Basic - Selecting folder with msoFileDialogFolderPicker Outlook VBA and Custom Forms 6
D Outlook 2016 Outlook not saving Sent Items Using Outlook 4
I Error saving screenshots in a custom form in outlook 2016, outlook 365 - ok in outlook 2013, outlook 2010 Outlook VBA and Custom Forms 5
I Saving attachments from multiple emails and updating file name Outlook VBA and Custom Forms 0
M Adding Subject to this Link-Saving VBA Outlook VBA and Custom Forms 5
D Saving Selected Emails as PDF and saving Attachments Outlook VBA and Custom Forms 6
B Saving items under a folder Using Outlook 3
R Quick Access view in File Explorer when saving attachments Using Outlook 0
N Saving And Deleting Outlook Attachments with Unknown Error Message Outlook VBA and Custom Forms 1
M Dialog called up multiple times when saving emails from macro Outlook VBA and Custom Forms 2
A saving attachement to folder named the same as rule name Outlook VBA and Custom Forms 0
T Saving all email to file folder in Windows Using Outlook 2
J Saving attachments from specific sender (phone number) to specific folder on hard drive Using Outlook 3
C Saving Outlook attachments and links to attachments with VBA Outlook VBA and Custom Forms 2
Kevin H Remotely saving emails Using Outlook 1
R Outlook 2010 Modify Style "Do not check spelling or grammar" not saving Outlook VBA and Custom Forms 0
R Outlook Office 365 not saving addresses Using Outlook 0
A Keep color categories when saving vCards Using Outlook 1
P Saving All Messages to the Hard Drive Using VBA Outlook VBA and Custom Forms 5
e_a_g_l_e_p_i question about saving my .pst so I can import it to my Outlook after I build a new system Using Outlook 10
S Editing an email with notes and saving it for record using Macro Outlook VBA and Custom Forms 3
O Saving Attachments to folder on disk and adding Initials to end of file name Outlook VBA and Custom Forms 9
J Outlook 2013 crashes saving VBA & clicking tools | digital signature Outlook VBA and Custom Forms 1
bifjamod Saving sent email to specific folder based on category with wildcard Outlook VBA and Custom Forms 1
N Saving .msg as sent item on send Outlook VBA and Custom Forms 1
erichamion Changes to meeting body not properly saving Outlook VBA and Custom Forms 4
A ItemAdd on Imap Folder get endless loop after saving item Using Outlook 5
T Saving Outlook 2010 email with attachments but read the email without Outlook Using Outlook 2
T From Field Blank when saving to folder other than Sent items Using Outlook 2
L Outlook DST (Daylight Saving Time) problem Using Outlook 0
F Using Outlook 2007 as an IMAP Mail Station Without Saving Data Locally Using Outlook 2
E Saving Changes To Edited E-Mail Received Message Using Outlook 0
D File Lock issue when saving message from Outlook to new folder Using Outlook 1
D Remove extension while saving attachments Using Outlook 1
K Printing & Saving Outlook Contacts Using Outlook 3
S Not saving attachments in the Sent Folder Using Outlook 2
S trouble with Outlook 2010 saving sent emails Using Outlook 2
D Saving outlook emails in html and attachments Using Outlook 4
W Default Saving a message as text Using Outlook 2
R Outlook 2007 QAT buttons not saving Using Outlook 2
C Exchange 2003 - Outlook 2003 - Calendar entries saving over each other Using Outlook 2
J Saving Published Outlook Form as msg Using Outlook 1
J Saving recent colors used for fonts in an email? Using Outlook 1

Similar threads

Back
Top