Solved

I need to open new Outlook Express email from my VB app.

Posted on 2003-10-29
8
537 Views
Last Modified: 2013-12-25
Hi,

I need the code I can use to click on  a button to run a new email using Outlook Express with To: supplied by me, just like pressing <a>href="mailto:......</a> in html pages.

Thanks
0
Comment
Question by:AbuMariam
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 2

Expert Comment

by:christatedavies
ID: 9641348
Stick this into the declarations of a module:

Public Declare Function ShellExecute Lib _
              "shell32.dll" Alias "ShellExecuteA" _
              (ByVal hwnd As Long, _
               ByVal lpOperation As String, _
               ByVal lpFile As String, _
               ByVal lpParameters As String, _
               ByVal lpDirectory As String, _
               ByVal nShowCmd As Long) As Long
               
Public Const SW_SHOW = 1

and then on the button_click code:

ShellExecute hwnd, "open", "mailto:emailaddress@domain.com", &O0, &O0, 1




HTH, Chris
0
 

Expert Comment

by:fishage
ID: 9642047
If you are positive that the user will be using Outlook Express, using this as your button handler would work too...

'----------------------------------------------------------------------
Dim obj, msg

Set obj = CreateObject("OutlookExpress.Application")
Set msg = obj.CreateItem(0)

msg.To = "no_reply@fakeaddress.com"
msg.Display
'----------------------------------------------------------------------

Chris has the better solution if you can't be positive, or if it is likely to ever change.
0
 

Author Comment

by:AbuMariam
ID: 9648445
Thanks guys, Chris code is working very well, for your code fishage, the problem is I cannot get the reference for OutlookExpress, I have only a reference for MicroSoftOutlook.

I need to put some details from the calling form in the body of the Mail, can it be done, I think the code of fishage will solve it if I had the reference to OutlookExpress

Thanks guys,  I do not know to whom should I give the points, please advice, I think chris was earlier, right?

AbuMariam
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

Author Comment

by:AbuMariam
ID: 9648449
Thanks guys, Chris code is working very well, for your code fishage, the problem is I cannot get the Project ---> References for OutlookExpress, I have only a reference for MicrosoftOutlook.

I need to put some details from the calling form in the body of the Mail, can it be done, I think the code of fishage will solve it if I had the reference to OutlookExpress

Thanks guys,  I do not know to whom should I give the points, please advice, I think chris was earlier?

AbuMariam
0
 
LVL 2

Expert Comment

by:christatedavies
ID: 9648454
You can do:

mailto:email@domain&subject=my subject&body=body text

Regards, Chris
0
 
LVL 2

Accepted Solution

by:
christatedavies earned 20 total points
ID: 9648458
Sorry, just to make it clearer, your code would be:

ShellExecute hwnd, "open", "mailto:emailaddress@domain.com&subject=This is a test&body=Just a little test to see what we can do", &O0, &O0, 1

Chris
0
 

Author Comment

by:AbuMariam
ID: 9648637
Thanks Chris,

But it is coming all in the (To:) field of the new mail, like this:

To: emailaddress@domain.com&subject=This is a test&body=Just a little test to see what we can do

0
 

Expert Comment

by:fishage
ID: 9652033
"Thanks guys,  I do not know to whom should I give the points, please advice, I think chris was earlier, right?"

Give the points to Chris.  I felt his answer was correct before I added my comment, i was just adding another way to do it... and it looks like I was wrong.  It appears that OutlookExpress can't be scripted the same way Outlook can.

Good luck with your application, it looks like you guys have it just about solved now.
0

Featured Post

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question