Solved

EASY MSEXCHANGE MSGS MAIL WITHIN VBA

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

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

Suggested Solutions

Title # Comments Views Activity
Run code from text file in vb 1 100
Set email body to html using vbscript 6 89
Formula problem with Excel attachment 6 44
SQL Server 2012 to SQL Server 2016 24 51
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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

738 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