Solved

EASY MSEXCHANGE MSGS MAIL WITHIN VBA

Posted on 1998-08-18
2
149 Views
Last Modified: 2010-04-30
Is there an easy way to simply make an MsExchange Message mailing from within a very small Visual Basic application?
0
Comment
Question by:cangeloni
2 Comments
 
LVL 3

Accepted Solution

by:
SPECIALIST earned 50 total points
ID: 1429565
a very basic program would be as follows:

Private Sub sendwitham()
Dim osession As Object
Dim omessage As Message


On Error Resume Next
Set osession = CreateObject("mapi.session")
If osession Is Nothing Then
Exit Sub
End If
osession.Logon
'If Err Then Exit Sub
Set omessage = osession.Outbox.Messages.Add
With omessage
Subject = txtsubject'this is a text box can also be hardcoded
Text = " " & txtnotetxt'text box can be hardcoded such as "hi"
End With

With omessage.Recipients.Add
Name = "email address"' can be also be text box

Type = mapiTo
Resolve
End With
If Len(txtattach) Then
With omessage.Attachments.Add
Position = 1
Type = mapiFileData
Name = txtattach' full path of file goes in this text box can be hardcoded too.
ReadFromFile txtattach
End With
End If
omessage.Send
osession.Logoff
MsgBox ("DONE")'optional


End Sub





Private Sub Command1_Click()
call sendwitham

End Sub

0
 

Author Comment

by:cangeloni
ID: 1429566
The system is reporting an error since it does not recognize the MESSAGE type in the second DIM statement.
Shall I have to put some other code into a Module to set the Message type?

Thanks
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…

758 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

17 Experts available now in Live!

Get 1:1 Help Now