-
Solved: Display e-mail message
Hello,
I have this script in a form I am building
[VBA]Sub cmdCreate_Click()
Dim MsgSubject As String
MsgSubject = txtSubject.Text
Set msg = Application.CreateItem(0)
msg.Subject = MsgSubject
msg.Body = "what you want to say in the body of the message"
msg.display
End Sub[/VBA]
but for some reason I cannot get the e-mail message to display on screen. I usually get a message saying that there is a dialog window still open.
If I take out the msg.display line then nothing happens at all when I press the button.
Is there a way around this or, to be more specific, what the hell am I doing wrong?
Cheers,
James
-
The code is fine in principle - except maybe you could declare the mail item variable[VBA]Dim msg as MailItem[/VBA]
But reading between the lines... well the first line actually, the procedure name "cmdCreate_Click" makes me suspect this is the event code on a user form commandbutton.
If the UserForm is modal (ShowModal property is True) then it won't allow Outlook to have the focus (and show a mailitem) until it's closed. If you have OL2000+, you can have non-modal forms, otherwise, you'll have to change the program flow so you call msg.Display from a standard module.
K :-)
-
Yup, a modal userform will generate the aforementioned error.
-
Modal and non-modal, eh? You learn something new everyday! Had to do a bit of searching to find out what it all meant but I found it and my problems (so far this morning) are solved! Huzzah!
Thanks very much.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules