Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

EASY MSEXCHANGE MSGS MAIL WITHIN VBA

Posted on 1998-08-18
2
Medium Priority
?
159 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

610 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