|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using Outlook objectIam trying to send an email on the click event of a button. This needs to work even if the outlook is not open in the client's pc. The following is the code: Set mOutlookApp = GetObject("", "Outlook.application") ' If Outlook is NOT Open, then there will be an error. ' Attempt to open Outlook If err.Number > 0 Then err.Clear Set mOutlookApp = CreateObject("Outlook.application") end if Set mItem = mOutlookApp.CreateItem(olMailItem) mItem.Recipients.Add strRecip mItem.Subject = strSubject mItem.HTMLBody = strMsg mItem.Send The above code works perfectly fine. The issue is, the client wants the message to be displayed to them (for any editing) before it is being sent. They want to click the 'send' button to send the email. I changed the code then to: mitem.display But this did not work for some reason. It did display the message window. But after clicking send button, the mail stays in the outbox. Only when we open the outlook, it is then being sent from the outbox. Why is this happening? Or is there any way I can give mitem.send from the code once the send button is clicked in the message? How to trap if the oulook object's send button is clicked? Thanks in advance.
Show quote
Hide quote
"NR" <N*@discussions.microsoft.com> wrote in message When you start Outlook, do you need to log in? If so, that explains why it's news:F8862246-F3FA-4165-B0B2-011FA94AF6FF@microsoft.com... > Hi, > > Iam trying to send an email on the click event of a button. This needs to > work even if the outlook is not open in the client's pc. > > The above code works perfectly fine. The issue is, the client wants the > message to be displayed to them (for any editing) before it is being sent. > They want to click the 'send' button to send the email. I changed the code > then to: > > mitem.display > > But this did not work for some reason. It did display the message window. > But after clicking send button, the mail stays in the outbox. Only when we > open the outlook, it is then being sent from the outbox. Why is this > happening? Or is there any way I can give mitem.send from the code once > the > send button is clicked in the message? How to trap if the oulook object's > send button is clicked? > not getting sent and only getting placed in the Outbox. You'd need to log in first. -- Mike Hi Mike, Jan
Thanks for your replies. But my problem is still not sorted out.. I do not need to login when I open outlook. Its automatic. Temporarily we made it work on the clients side by using message.send instead of using message.display. But now they are specific about having the message displayed on the screen so that they can check/change the contents of the mail before clicking the 'send' button on the screen. Hence I have to use the message.display. But as I stated earlier, when I use this, the message is not sent. And it is in the outbox. Only when I open the outlook, its sent. I also seem to have found the reason for this: Once the mail is displayed to the user using message.display, thats the last line in the email function code, and hence it comes out of the function. Now, when the user clicks on the 'send' button, how to trap and give message.send? I am not desperate to fix this asap. Pl help. Thanks, Show quoteHide quote "MikeD" wrote: > > "NR" <N*@discussions.microsoft.com> wrote in message > news:F8862246-F3FA-4165-B0B2-011FA94AF6FF@microsoft.com... > > Hi, > > > > Iam trying to send an email on the click event of a button. This needs to > > work even if the outlook is not open in the client's pc. > > > > The above code works perfectly fine. The issue is, the client wants the > > message to be displayed to them (for any editing) before it is being sent. > > They want to click the 'send' button to send the email. I changed the code > > then to: > > > > mitem.display > > > > But this did not work for some reason. It did display the message window. > > But after clicking send button, the mail stays in the outbox. Only when we > > open the outlook, it is then being sent from the outbox. Why is this > > happening? Or is there any way I can give mitem.send from the code once > > the > > send button is clicked in the message? How to trap if the oulook object's > > send button is clicked? > > > > > When you start Outlook, do you need to log in? If so, that explains why it's > not getting sent and only getting placed in the Outbox. You'd need to log > in first. > > -- > Mike > > Try posting to one of these groups:
microsoft.public.outlook.program_vba microsoft.public.office.developer.outlook.vba
Show quote
Hide quote
"NR" <N*@discussions.microsoft.com> wrote in message I'm guessing there should not be a "not" in that last sentence. <g>news:4ED6D3E4-FB36-496C-A9D2-7B0CD6EB4957@microsoft.com... > Hi Mike, Jan > > Thanks for your replies. But my problem is still not sorted out.. I do not > need to login when I open outlook. Its automatic. > > Temporarily we made it work on the clients side by using message.send > instead of using message.display. > > But now they are specific about having the message displayed on the screen > so that they can check/change the contents of the mail before clicking the > 'send' button on the screen. > > Hence I have to use the message.display. But as I stated earlier, when I > use > this, the message is not sent. And it is in the outbox. Only when I open > the > outlook, its sent. > > I also seem to have found the reason for this: Once the mail is displayed > to > the user using message.display, thats the last line in the email function > code, and hence it comes out of the function. Now, when the user clicks on > the 'send' button, how to trap and give message.send? > > I am not desperate to fix this asap. Pl help. I tend to agree with Nobody. I think this is probably more an Outlook issue than a VB issue and therefore posting in an Outlook newgroup would be your best bet. Actually, your BEST option is to not use Outlook, or any email client, at all. The main reason being is that Outlook (and Outlook Express and Windows Mail [Vista and later]) have a "feature" to prevent, or at last make more difficult, an application from using them to send email. Instead, provide a means in your app to allow the user to compose or edit the email message and then use something like CDO to send it. CDO stands for Collaboration Data Objects and is included with Windows 2000 and later. So the added benefit is that your application is not dependent on a specific email client being installed. The downside to using CDO (and pretty much any other way of sending email) is there will be some configuration necessary. For example, with CDO, the user will need to provide their SMTP server. So, provide in your app a place to specify this and save it so that the user doesn't need to provide it every time an email is sent. If necessary, save it where it can be obtained regardless of user. If your app is run by users from multiple workstations, save it where any workstation can obtain it. Depending on the SMTP server, credentials (a user name and password) might be required too. -- Mike
Karl, I need to understand your Timer!
RAM Drive can't write to text file in Windows 7 I need a Class 101 on threading in VB6 Ghost Form Run-Time Error 5 - 'Invalid procedure call or argument' error msg Overcoming a MsgBox's shyness File not found How to obtain the new GUIID key on a new build of an ActiveX DLL or an ActiveX OCX Autosize DataGrid Columns |
|||||||||||||||||||||||