Link to home
Start Free TrialLog in
Avatar of AbuMariam
AbuMariam

asked on

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

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
Avatar of christatedavies
christatedavies

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
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.
Avatar of AbuMariam

ASKER

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
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
You can do:

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

Regards, Chris
ASKER CERTIFIED SOLUTION
Avatar of christatedavies
christatedavies

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

"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.