![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
Outlook 2002:
Attachments to a Mailitem object are not attached when the code runs at normal speed, but are attached if I place a Break on the Display line (last line in code snippet below) and press F8 to execute the Display statement in step mode. Although the MailItem is saved before attaching the attachments, I'm still getting this inconsistent result. It seems like a timing issue, but DoEvents doesn't help. Any clues please? Very many thanks. Regards Geoff Dim objMI as Outlook.MailItem Dim objATTACHMENTS as Outlook.Attachments Set objMI = mobjOL.CreateItem(olMailItem) .... some objMI properties set here, like "To"... objMI.Save Set objATTACHMENTS = objMI.Attachments objATTACHMENTS.Add "PathNameToFile", olByValue objMI.Display |
Ads |
#2
|
|||
|
|||
![]()
Try saving the item again after you add the attachments.
-- 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 "Geoff" wrote in message ... Outlook 2002: Attachments to a Mailitem object are not attached when the code runs at normal speed, but are attached if I place a Break on the Display line (last line in code snippet below) and press F8 to execute the Display statement in step mode. Although the MailItem is saved before attaching the attachments, I'm still getting this inconsistent result. It seems like a timing issue, but DoEvents doesn't help. Any clues please? Very many thanks. Regards Geoff Dim objMI as Outlook.MailItem Dim objATTACHMENTS as Outlook.Attachments Set objMI = mobjOL.CreateItem(olMailItem) ... some objMI properties set here, like "To"... objMI.Save Set objATTACHMENTS = objMI.Attachments objATTACHMENTS.Add "PathNameToFile", olByValue objMI.Display |
#3
|
|||
|
|||
![]()
Hi Ken,
Try saving the item again after you add the attachments. Thanks for your reply. I thought you might like to know the rather interesting result. It transpires my clean up code was in error. By trying to ensure that the attachments object variable was "properly" destroyed, my clean up code removed each attachment from the attachments collection before setting the attachments collection variable to nothing. Naturally, the clean up code ran *after* the Display method was used, so the MailItem was already on screen when the clean up code ran. Although it happened too fast to see it, the attachments were in the MailItem initially but were removed so fast as not to be seen. What's interesting is that, if the code was stopped any time after the Display method but before the clean up, the attachments could be seen in the MailItem. Stepping through the clean up code showed each attachment being removed one at a time from the MailItem as the attachment was removed from the attachments collection. Interestingly, as might be expected, this behaviour was *not* replicated for the Send method. Presumably, after Send, the MailItem is already in the Outbox by the time my clean up code ran and it was too late for the clean up code to remove attachments. Omitting removal of attachments from the attachments collection solved the problem when using the Display method. If you (or others) have any further comments, I'd be glad to hear them. Thanks for your interest. Regards Geoff |
#4
|
|||
|
|||
![]()
If the user hasn't started Outlook, is there a way of making Outlook visible
after CreateObject("Outlook.Application")? TIA. Geoff |
#5
|
|||
|
|||
![]()
Dim oNS As Outlook.NameSpace
Dim oInbox As Outlook.MAPIFolder Dim oExpl As Outlook.Explorer Set oNS = oOL.GetNameSpace("MAPI") oNS.Logon Set oInbox = oNS.GetDefaultFolder(olFolderInbox) Set oExpl = oInbox.GetExplorer oExpl.Display -- 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 "Geoff" wrote in message ... If the user hasn't started Outlook, is there a way of making Outlook visible after CreateObject("Outlook.Application")? TIA. Geoff |
#6
|
|||
|
|||
![]()
Hi Ken,
Very many thanks. Easy when you know how! I was pretty ashamed at having to ask such a basic question. But by way of explanation, I'm more used to the Access, Word and Excel object models. The Outlook object model is a mystery. From where I'm coming from, it seemed logical to look for an Application.Visible property or an Application.hWnd property (to use an API call). It didn't occur to me that getting an explorer on one folder within the application would reveal the whole application. I've read the wrong books on Outlook. I have several, but not, I regret to say, by you. I'm primarily an Access developer. Do you have any recommendations for an Outlook reference I can dip into to find solutions, not a course book that makes too many presuppositions about earlier knowledge? I'm not a serious Outlook developer but I want a good grounding in Outlook programming basics. I'll do course work if it's engaging, not if it's dry as dust. I see some of your older books are being sold at bargain prices on Amazon. Given the above, would any of them fit the bill for an Office 2002 developer? Don't be bashful but an honest answer please! We retired nerds are not rolling in it you know! I'm happy to invest in several. And a good one for the future direction of Outlook. Let me know if you can't answer for Newsgroup conduct reasons and perhaps I could try you at mvps? Thanks again. Regards Geoff "Ken Slovak - [MVP - Outlook]" wrote in message ... Dim oNS As Outlook.NameSpace Dim oInbox As Outlook.MAPIFolder Dim oExpl As Outlook.Explorer Set oNS = oOL.GetNameSpace("MAPI") oNS.Logon Set oInbox = oNS.GetDefaultFolder(olFolderInbox) Set oExpl = oInbox.GetExplorer oExpl.Display -- 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 |
#7
|
|||
|
|||
![]()
There's virtually nothing out there that deals with things on the level of
hWnd's or Win32 API calls. That sort of stuff is all undocumented and what I know about it is what I've hacked. By the same token try to find any Office app that exposes a hWnd property. When I need that, which I often do I first try GetForeGroundWindow and from there move to more obscure coding, especially when WordMail windows are involved. For a beginner in Outlook programming I'd highly recommend Sue Mosher's book. It's geared for beginners who know VBA/VBScript/VB and covers Outlook VBA and forms, but not COM addins. The only Outlook 2002 programming books I know of are Randy Byrne's Building Applications with Microsoft Outlook 2002 from MS Press and Tom Rizzo's Programming Outlook & Exchange, also from MS Press. I think Randy's is better, but neither is a beginner Outlook book. My Wrox book is geared to the professional level also, the Sams book was written for beginners but marketed for professional level. I have reservations about that book, the lead author wasn't really an Outlook programmer (although my chapters are excellent g). There will be a few Outlook 2007 programming books coming out, Randy is doing one and so am I. Sue is also updating her book. I'm not sure about Tom, I haven't spoken to him in a while. I'd say start with Sue's book: http://www.outlookcode.com/jumpstart.aspx. She's a great teacher and writes very clearly and her credentials are impeccable. That I was her tech editor I don't think prejudices me very much ![]() -- 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 "Geoff" wrote in message ... Hi Ken, Very many thanks. Easy when you know how! I was pretty ashamed at having to ask such a basic question. But by way of explanation, I'm more used to the Access, Word and Excel object models. The Outlook object model is a mystery. From where I'm coming from, it seemed logical to look for an Application.Visible property or an Application.hWnd property (to use an API call). It didn't occur to me that getting an explorer on one folder within the application would reveal the whole application. I've read the wrong books on Outlook. I have several, but not, I regret to say, by you. I'm primarily an Access developer. Do you have any recommendations for an Outlook reference I can dip into to find solutions, not a course book that makes too many presuppositions about earlier knowledge? I'm not a serious Outlook developer but I want a good grounding in Outlook programming basics. I'll do course work if it's engaging, not if it's dry as dust. I see some of your older books are being sold at bargain prices on Amazon. Given the above, would any of them fit the bill for an Office 2002 developer? Don't be bashful but an honest answer please! We retired nerds are not rolling in it you know! I'm happy to invest in several. And a good one for the future direction of Outlook. Let me know if you can't answer for Newsgroup conduct reasons and perhaps I could try you at mvps? Thanks again. Regards Geoff |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help - can't add "Item" (of type MailItem) using Attachments.Add() | [email protected] | Outlook and VBA | 1 | August 3rd 06 05:55 AM |
OL2003: Open Mailitem | René Panzeri | Outlook and VBA | 3 | July 9th 06 08:49 PM |
MailItem Folder Path | Fox via OfficeKB.com | Outlook and VBA | 1 | July 7th 06 02:39 PM |
Read body of MailItem ? | Trey Shaffer | Outlook and VBA | 1 | March 18th 06 07:56 PM |
How can I create a MailItem that displays like a received MailItem ? | Clive | Outlook - Using Forms | 0 | February 27th 06 04:14 PM |