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
Solved

Manipulate exchange in code

Posted on 1998-08-02
3
161 Views
Last Modified: 2010-05-03
i want to code the proccess of opening exchange, creating a new message and attaching a specified file to the message.
how do i do that?

yny
0
Comment
Question by:yny
3 Comments
 
LVL 3

Expert Comment

by:SPECIALIST
ID: 1467509
This is a great program that will do this for you:

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 textbox on your form, you can hard code this too eg "birthday"

Text = " " & txtnotetxt' same as above can be hardcoded same way
End With

With omessage.Recipients.Add
Name = txtname'please note this is a text box, you can hard code this eg "JONdoe@aol.com"

Type = mapiTo
Resolve
End With
If Len(txtattach) Then 'txtattach is a textbox that has the full path and name of the file to attach can be hardcoded "c:\autoexecbat", but remember to change ALL references to TXTATTACH.
With omessage.Attachments.Add
Position = 1
Type = mapiFileData
Name = txtattach
ReadFromFile txtattach
End With
End If
omessage.Send
osession.Logoff
MsgBox ("DONE")'optional


End Sub





Private Sub Command1_Click()
sendwitham

End Sub

0
 

Author Comment

by:yny
ID: 1467510
Hi!
I am familiar with this kind of solution but its not enough.
i want to open the exchange itself,so the user would be able to locate an address in the address list & send the message to few Recipients, without knowing theire addresses in advance.
 
0
 

Accepted Solution

by:
Rishi080198 earned 200 total points
ID: 1467511
Hi! ymy, I think the following code should solve yur problem. It will open your mail utility( exchange etc) and give you all the options thereafter.

I have added the foolowing code on the click of a button:
 

Private Sub Command1_Click()
Dim objSession As Object    ' Session object
Dim objMessage As Object     ' Message object

On Error GoTo error_olemsg
   
 ' create a session then log on, supplying username and password
 Set objSession = CreateObject("MAPI.Session")

 ' change the parameters to valid values for your configuration
 objSession.Logon

 ' create a message and fill in its properties
 Set objMessage = objSession.Outbox.Messages.Add

' the following line is important because it will open your mail ' utility
objMessage.Send True, True, 0 '(savecopy,showdialog,parentwindow)

 objSession.Logoff
    Exit Sub
   
error_olemsg:
    'MsgBox "Error " & Str(Err) & ": " & Error$(Err)
    Exit Sub

End Sub

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
bit defender blocks good applications 2 101
VBA filters 2 64
how to know if my Checkbox is True in VB6.0? 9 60
transition to visual .net from vb6 5 36
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…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…

790 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