Link to home
Start Free TrialLog in
Avatar of steve_mills
steve_mills

asked on

Emailing from VB5

I would like to put an option into my application so the user can email the database to a someone else.

So it would have to open Outlook up and then attach the databse to a new amil message.

Is this possable and if so has any one have some code I can get started with.

Thanks
Steve
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

Avatar of steve_mills
steve_mills

ASKER

This is a good link but I am using VB5.0 sorry

Thanks
Steve
you have 2 options:

1. since you have all the source code, try opening it into VB5 and compile it.

2. Use the DLL and distribute it with your app (do not forget msvbvm60.dll and maybe other requirements that I could tell you).
Hi!

Here's a file for you over the net:

View code...
http://www.planetsourcecode.com/vb/scripts/ShowCodeAsText.asp?txtCodeId=5946&lngWId=1
Description: This code will send email through MS Outlook 98, (or the most current version on your computer), using MS Excel 7.0 or higher.

That's it!

glass cookie : )

PS. If you've received an error message saying that 'Retained' is an invalid keyword or something similiar to that, simply open the vbp file in txt format and remove te line:

Retained = 0

That's all : )
Can can not open the .vbp files I get an error
Retained is an invalid key.

And I cannot load the dll into my project either.

Thanks
Steve
delete the retained line from the VBP file. it is a compilation option in VB6.
glass cookie
this code works but I would like it to show the send mail form from outlook so the user can select the recipient of the mail message from the global address book.

Thanks
steve
Look at this code,

http://www.freevbcode.com/ShowCode.Asp?ID=3886

Cheers

Narayanan
Or this one will work in VB5 also

http://www.freevbcode.com/ShowCode.Asp?ID=159

Narayanan
I am appending the above referenced code from freevbcode.com for your quick reference,

====================================================
The owner of the code is Stanley Campbell and not me.
=====================================================

Public Sub SendOutlookMail(Subject As String, Recipient As _
String, Message As String)

On Error GoTo errorHandler
Dim oLapp As Object
Dim oItem As Object

Set oLapp = CreateObject("Outlook.application")
Set oItem = oLapp.createitem(0)
'
With oItem
   .Subject = Subject
   .To = Recipient
   .body = Message
   .Send
End With
'
Set oLapp = Nothing
Set oItem = Nothing
'

Exit Sub

errorHandler:
Set oLapp = Nothing
Set oItem = Nothing
Exit Sub
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

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
I have acheived a good starting piont with this code.
I know see outlook and have been able to attach the required doc., put in a recp name if I want to ect.

Thanks