Open olNoteItem Attachment

Status
Not open for further replies.

Emmy

Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server 2013
Hi,

I've written some code which creates and then attaches a blank Note to an e-mail:

Code:
Sub AddNote()

Dim objExplorer As Explorer
Dim OutlookMsg  As MailItem
Dim objNote As Object

Set objExplorer = Outlook.Application.ActiveExplorer

If objExplorer.Selection.Count = 0 Then
    MsgBox "An e-mail needs to be selected"
    Exit Sub
Else
    Set OutlookMsg = objExplorer.Selection.Item(1)
End If

Set objNote = Outlook.Application.CreateItem(olNoteItem)

objNote.Save

OutlookMsg.Attachments.Add objNote

objNote.Delete

End Sub

This works exactly as I want with one bit missing - how do I open the attached note so it is ready for the user to add some text directly, without having to double click to open it?

I have done some Googling and found that Outlook will save copies of attachments in a temporary folder when you want to open it but when I tried this, the text I added to the opened note was not saved to the note attached to the e-mail. I am able to achieve this manually though - if I run the code above, open the note by double clicking, add some text, close the note and then re-open it - the text I added still remains in the note attached to the e-mail.

Any help on this would be much appreciated.

Thanks,

Emmy
 
If i change delete to display, it opens the note but the changes aren't saved to the message (they are saved to the note in the Notes folder) but a bigger problem is that outlook treats it as a message when i reopen it, unless i add something to the body before it's added as an attachment.


Set objNote = Outlook.Application.CreateItem(olNoteItem)
objNote.Body = Time
objNote.Save
OutlookMsg.Attachments.Add objNote
objNote.Delete


What you need to do is close the attachment then open it - that should allow you to edit it and save the changes. Or use an inputbox to get the note before it's saved.
 
Hi Diane,

Thanks very much for looking at this for me.

What do you mean - when you say I need to close the attachment first? I don't see the attachment as open.

Thanks,

Emmy
 
Sorry about that, i meant clear the object - which delete does - then reopen it using code. This should replicate the double click to open steps, which you said worked.

FWIW, when i double clicked to open and added text using 2016, the changed note was saved in notes but not in the attachment.
 
Hi Diane,

How do I open the attachment though? The attached note doesn't seem to be stored in the Outlook temporary folder.

If I run my code and then double click on the attachment the note opens up like this (with my Inbox in the background) but if I check the temporary folder nothing is there.

View attachment 1830

I'm trying to add the double click to my code but as the attached note isn't in the temporary folder I'm not sure how.

If however I use
Code:
OutlookMsg.Attachments(1).SaveAsFile "C:\Users\ekav\AppData\Local\Microsoft\Windows\Temporary Internet Files\Content.Outlook\7Y0WQL3M\Note.msg"
to save the attachment in the temporary folder and then use ShellExecute to open it, the text I type into the note is not saved in the attachment but is in the note in the temporary folder.

It's super annoying as it's just the double click I'm trying to replicate as when I open the note by double clicking on it and type into the resulting note pop-up this text is stored/saved within the attachment when the note is closed.

Perhaps this isn't possible via VBA? In which case the user can just open the note manually by double clicking on it before typing in the text...

Thanks again for looking at this.

Emmy
 
Because it's an outlook item, it's not stored in the temp folder. It may not be possible to open it using code - i'll look into it but not holding my breath.
 
OK, thanks Diane. Not to worry and much appreciated.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Rupert Dragwater How to get Outlook 365 to open from websites Using Outlook 5
Witzker Outlook 2019 Edit contact from email does not open the user defined contactform Using Outlook 3
S Leaving ActiveExplorer open for editing after Sub is done Outlook VBA and Custom Forms 0
Commodore PDF attachments started to open in Edge Using Outlook 0
T Outlook 2021 Cannot open attachments Outlook DeskTop 2021 Using Outlook 0
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
talla Can't open Outlook Item. Using Outlook 0
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
K Embedded photos no longer open with Photos or Photo Viewer Using Outlook 7
Witzker Open Contact missing in Outlook 2019 Using Outlook 2
L Cannot open PST file for first session each day Using Outlook 6
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
W Automatically open attachments without automatically printing them Using Outlook 0
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
C Can't Open Outlook 365 Using Outlook 0
D after delete mail, open the next one Outlook VBA and Custom Forms 0
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M outlook won't open! Using Outlook 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
M other user's mailbox won't open, forms disappeared Using Outlook 42
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D Add Tetxbox at form open Outlook VBA and Custom Forms 1
U Catching ModuleSwitch events after "open in new window" Outlook VBA and Custom Forms 2
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
S Reminder Dialog Open Button Using Outlook 2
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
S Outlook 2010 Cannot Open Attachments Using Outlook 14
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A open Outlook with multiple windows. Using Outlook 0
K open calendar from address book Outlook VBA and Custom Forms 1
T Double clik behavior on agenda open a new meeting request Using Outlook 1
G Can't open .pst. Message could not access default folder (Outlook 2010 (.pst). Before that was backi Using Outlook 0
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item Using Outlook 0
O Windows 10 x64 Outlook 2013 - URL does not open (anymore) Using Outlook 3
Hudas VBA find and open an email without looping thru each email in the inbox Outlook VBA and Custom Forms 1
Diane Poremsky Rules & Alerts Dialog Won't Open Using Outlook 1
Diane Poremsky Outlook 2013: Control Panel Mail Won't Open Using Outlook 0
O Cannot open or save calendar items Using Outlook 0

Similar threads

Back
Top