English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I am trying to send an email with VB but am getting stuck on the dim. It stops at the first line:

dim olapp as Outlook.Application

and returns the message: User-defined type not defined

Is there a component or reference I need to add to my program in order for this to work? I have a different way of getting the email ready, by using:

'ShellExecute ByVal 0&, vbNullString, str, vbNullString, "C:\", SW_SHOWNORMAL

with my parameters but I can not figure out if there is a way for it to automatically send. So I'm looking through previous posts and I came across the example:

dim olapp as Outlook.Application
dim olmsg As Outlook.MailItem
olmsg.Recipients.Add "Recipients"
olmsg.Attachments.Add "c:\test.txt"
olmsg.Subject = "Subject"
olmsg.Body = "Body"
olmsg.send

I see it should be easy to send a "send" command but I'm getting hung up. Any ideas? Thanks!

2007-02-28 06:23:54 · 2 answers · asked by Donderman 1 in Computers & Internet Programming & Design

2 answers

You're right, you need the reference to "Microsoft Outlook 10 Objects" (name may vary depending on Outlook you are using). Also, you must have the Outlook installed too, in order that the code works. And, additionally, you need the Outlook objects library, which is on the Office Setup CD, but must be installed separately.
Try to use MAPI instead, there is a MAPI control in VB6. It will work with all e-mail clients.

2007-02-28 23:17:07 · answer #1 · answered by BataV 3 · 0 0

Dim OutlookApp As Outlook.Application
Dim OutlookMailItem As Outlook.MailItem

Set OutlookApp = New Outlook.Application
Set OutlookMailItem = OutlookApp.CreateItem(olMailItem)


you need a "New" command

2007-02-28 06:56:07 · answer #2 · answered by peterchoi77 2 · 1 0

fedest.com, questions and answers