Solved

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

Posted on 2003-10-29
8
511 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
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…

707 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

16 Experts available now in Live!

Get 1:1 Help Now