views:

98

answers:

2

I'm trying to set up a form where the user can click on a button and it pulls the email address of a contact, creates a new email, allows the user to type out their email and send it, then save the email into a table.

I have it working, except for one little issue. In earlier versions of Outlook (2003 and earlier), you can set up Word as the email editor. If this is the case, the code never completes.

 Dim objOutlook As Object 
 Dim objmessage As Object 
 Dim myInspector As Variant

 Set objOutlook = CreateObject("outlook.application", "localhost")
 Set objmessage = objOutlook.createItem(0)
 objmessage.To = Me!email
 Set myInspector = objmessage.GetInspector
 myInspector.display

 (v THIS IS THE CODE THAT LOOPS, SEE BELOW v)
 While Not myInspector.CurrentItem Is Nothing
    DoEvents
 Wend

When Outlook is the email editor, the while block marked above loops until the user either sends or closes the email message (myInspector.CurrentItem gets cleared). It then continues from there to pull the information back into Access. However, when Word is the email editor, the code marked above loops forever (myInspector.CurrentItem never gets cleared). Anyone know why it might be doing this? And if you do, what can I do to resolve this so it works for Word as the email editor like it does for Outlook?

A: 

It is true that, when you open outlook with Word as an editor, you are creating new instances of both Outlook AND Word. You should be able to cancel the use of Word as your editor through the OutlookMsg object.

If messages are really simple, and without attachments, you can also type them in a memo control and send them directly from Access (sendObject command), but then they won't be saved to Outlook.

Philippe Grondier
Unfortunately, the customer is requiring the ability to use Word as their e-mail editor.
KevenDenen
Your client is very stupid.
David-W-Fenton
It is always interesting to understand why your customer would make the use of Word as email editor mandatory. Depending on its 'software knowledge', its arguments could be technically acceptable, which I doubt. You might discover that people asked you to follow a rule without any other justification than 'this is the way we do it'.
Philippe Grondier
And by the way, clients are not stupid. They are clients
Philippe Grondier
+1  A: 
 While Not objOutlook.ActiveInspector Is Nothing
    DoEvents
 Wend

It worked on mine. Please check this if it is going to work.

THEn
Right on. Worked like a charm.
KevenDenen