Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Emailing from VB5

Posted on 2002-04-22
12
Medium Priority
?
168 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:steve_mills
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6961837
0
 

Author Comment

by:steve_mills
ID: 6961853
This is a good link but I am using VB5.0 sorry

Thanks
Steve
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6961856
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).
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:glass_cookie
ID: 6961868
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 : )
0
 

Author Comment

by:steve_mills
ID: 6961874
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
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 6961878
delete the retained line from the VBP file. it is a compilation option in VB6.
0
 

Author Comment

by:steve_mills
ID: 6961922
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
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6962252
Look at this code,

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

Cheers

Narayanan
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6962255
Or this one will work in VB5 also

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

Narayanan
0
 
LVL 3

Expert Comment

by:n_narayanan
ID: 6962263
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
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 300 total points
ID: 6962369
You can use this to create and DISPLAY an Outlook message (this code is in a class for me):

Private mstrAddressTo As String
Private mstrBody As String
Private mstrSubject As String

Public Property Get AddressTo() As String
    AddressTo = mstrAddressTo
End Property
Public Property Let AddressTo(ByVal vdata As String)
    mstrAddressTo = vdata
End Property


Public Property Get Body() As String
    Body = mstrBody
End Property
Public Property Let Body(ByVal vdata As String)
    mstrBody = vdata
End Property


Public Property Get Subject() As String
    Subject = mstrSubject
End Property
Public Property Let Subject(ByVal vdata As String)
    mstrSubject = vdata
End Property

Public Sub SendMailWithOutlook()
Dim objMessage As Object  'Outlook.MailItem
Dim objOutlook As Object  'Outlook.Application

    On Error GoTo ErrHandler
   
    Set objOutlook = CreateObject("Outlook.Application")
    Set objMessage = objOutlook.CreateItem(0)  '(olMailItem)

    With objMessage
        If Len(Trim$(AddressTo)) = 0 Then
            .recipients.Add " "  '"someone@somewhere.com"
        Else
            .recipients.Add AddressTo
        End If
        .Subject = Subject
        .Body = Body
        .Display
    End With
    Set objMessage = Nothing
    Set objOutlook = Nothing
   
    Exit Sub
   
ErrHandler:
    If Err.Number = -2147024894 Then
        MsgBox "An error occured while trying to attach " & Attachments & " to the e-mail!!!" & _
               vbCrLf & vbCrLf & _
               "Error: " & Err.Number & ": " & Err.Description
    Else
        MsgBox "An error occured while trying to prepare an e-mail!!!" & _
               vbCrLf & vbCrLf & _
               "Error: " & Err.Number & ": " & Err.Description
    End If
End Sub
0
 

Author Comment

by:steve_mills
ID: 6964892
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

618 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