Solved

EASY MSEXCHANGE MSGS MAIL WITHIN VBA

Posted on 1998-08-18
2
152 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
consolidate or create a new vba code for performing tasks 5 66
Updates not working for MS Windows 7 12 166
using Access 8 69
MsgBox 4 61
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…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

831 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