Solved

EASY MSEXCHANGE MSGS MAIL WITHIN VBA

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

707 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