Solved

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

Posted on 2003-10-29
8
518 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
  • 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

929 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now