Solved

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

Posted on 2003-10-29
8
523 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
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

 

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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restricting text box entry from \/:?<>"| 9 86
Problem to skip loop 6 57
VBA to copy paste columns form one file to other 20 87
Error with a code discussed on this page 5 14
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

770 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