Link to home
Start Free TrialLog in
Avatar of yny
yny

asked on

Manipulate exchange in code

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
Avatar of SPECIALIST
SPECIALIST

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

Avatar of yny

ASKER

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.
 
ASKER CERTIFIED SOLUTION
Avatar of Rishi080198
Rishi080198

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial