Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help about outlook automation sample

Status
Not open for further replies.

kosta

Programmer
Feb 9, 2001
186
0
0
CA
how can i add "send/receive" button this sample ?

**************************************************
Public oform1
oform1=createobject("form1")
oform1.Show
Return
**************************************************
Define Class form1 As Form

Height = 400
Width = 620
DoCreate = .T.
Caption = "Form1"
Name = "Form1"

Add Object cmdExit As CommandButton With ;
Top = 330, ;
Left = 504, ;
Height = 27, ;
Width = 84, ;
Caption = "E<xit", ;
Name = "CmdExit"

Add Object cmdCalendar As CommandButton With ;
Top = 330, ;
Left = 12, ;
Height = 27, ;
Width = 84, ;
Caption = "<Calendar", ;
Name = "CmdCalendar"

Add Object cmdInBox As CommandButton With ;
Top = 330, ;
Left = 108, ;
Height = 27, ;
Width = 84, ;
Caption = "<In Box", ;
Name = "CmdInBox"

Add Object cmdSent As CommandButton With ;
Top = 330, ;
Left = 204, ;
Height = 27, ;
Width = 84, ;
Caption = "<Sent Mail", ;
Name = "CmdSent"

Add Object cmdContact As CommandButton With ;
Top = 330, ;
Left = 300, ;
Height = 27, ;
Width = 84, ;
Caption = "<AddressBook", ;
Name = "CmdContact"

Add Object cmdNewMail As CommandButton With ;
Top = 360, ;
Left =12 , ;
Height = 27, ;
Width = 84, ;
Caption = "New <Mail", ;
Name = "cmdNewMail"

Add Object cmdNewTask As CommandButton With ;
Top = 360, ;
Left =108 , ;
Height = 27, ;
Width = 84, ;
Caption = "New <Task", ;
Name = "cmdNewTask"

Add Object cmdNewContact As CommandButton With ;
Top = 360, ;
Left =204 , ;
Height = 27, ;
Width = 84, ;
Caption = "<New Contact", ;
Name = "cmdNewContact"

Add Object cmdNewAppointment As CommandButton With ;
Top = 360, ;
Left =300 , ;
Height = 27, ;
Width = 110, ;
Caption = "New A<ppointment", ;
Name = "cmdNewAppointment"

Add Object olecontrol1 As OleControl With ;
Top = 12, ;
Left = 12, ;
Height = 306, ;
Width = 588, ;
Name = "Olecontrol1", ;
OleClass = "OVCtl.OVCtl.1"

Procedure cmdExit.Click
Thisform.Release()
Endproc

Procedure cmdNewMail.Click
Thisform.olecontrol1.NewMessage()
ENDPROC

Procedure cmdNewTask.Click
Thisform.olecontrol1.NewTask()
Endproc

Procedure cmdNewContact.Click
Thisform.olecontrol1.NewContact()
ENDPROC

Procedure cmdNewAppointment.Click
Thisform.olecontrol1.NewAppointment()
Endproc

Procedure cmdCalendar.Click
Thisform.olecontrol1.Folder = "CALENDAR"
Thisform.Caption = "OutLook Calendar"
Thisform.Refresh()
Endproc

Procedure cmdInBox.Click
Thisform.olecontrol1.Folder = "INBOX"
Thisform.Caption = "OutLook InBox"
Thisform.Refresh()
Endproc

Procedure cmdSent.Click
Thisform.olecontrol1.Folder = "SENT ITEMS"
Thisform.Caption = "OutLook Sent Items"
Thisform.Refresh()
Endproc

Procedure cmdContact.Click
Thisform.olecontrol1.Folder = "CONTACTS"
Thisform.Caption = "OutLook Address Book"
Thisform.Refresh()
Endproc

Procedure olecontrol1.Init
This.Folder = "InBox"
Endproc

Enddefine
*******************************************************
** EOF
*******************************************************

Soykan OEZCELIK
 
Yes you can

Code:
Public oform1
oform1=Createobject("form1")
oform1.Show
Return
**************************************************
Define Class form1 As Form

	Height = 400
	Width = 620
	DoCreate = .T.
	Caption = "Form1"
	Name = "Form1"

	Add Object cmdExit As CommandButton With ;
		Top = 330, ;
		Left = 504, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "E<xit", ;
		Name = "CmdExit"

	Add Object cmdCalendar As CommandButton With ;
		Top = 330, ;
		Left = 12, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "<Calendar", ;
		Name = "CmdCalendar"

	Add Object cmdInBox As CommandButton With ;
		Top = 330, ;
		Left = 108, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "<In Box", ;
		Name = "CmdInBox"

	Add Object cmdSent As CommandButton With ;
		Top = 330, ;
		Left = 204, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "<Sent Mail", ;
		Name = "CmdSent"

	Add Object cmdContact As CommandButton With ;
		Top = 330, ;
		Left = 300, ;
		Height = 27, ;
		Width = 84, ;
		Caption = "<AddressBook", ;
		Name = "CmdContact"

	Add Object cmdNewMail As CommandButton With ;
		Top = 360, ;
		Left =12 , ;
		Height = 27, ;
		Width = 84, ;
		Caption = "New <Mail", ;
		Name = "cmdNewMail"

	Add Object cmdNewTask As CommandButton With ;
		Top = 360, ;
		Left =108 , ;
		Height = 27, ;
		Width = 84, ;
		Caption = "New <Task", ;
		Name = "cmdNewTask"

	Add Object cmdNewContact As CommandButton With ;
		Top = 360, ;
		Left =204 , ;
		Height = 27, ;
		Width = 84, ;
		Caption = "<New Contact", ;
		Name = "cmdNewContact"

	Add Object cmdNewAppointment As CommandButton With ;
		Top = 360, ;
		Left =300 , ;
		Height = 27, ;
		Width = 110, ;
		Caption = "New A<ppointment", ;
		Name = "cmdNewAppointment"
	Add Object cmdSendandReceive As CommandButton With ;
		Top = 360, ;
		Left =504 , ;
		Height = 27, ;
		Width = 110, ;
		Caption = "Send and Receive", ;
		Name = "cmdSendandReceive"

	Add Object olecontrol1 As OleControl With ;
		Top = 12, ;
		Left = 12, ;
		Height = 306, ;
		Width = 588, ;
		Name = "Olecontrol1", ;
		OleClass = "OVCtl.OVCtl.1"

	Procedure cmdExit.Click
		Thisform.Release()
	Endproc

	Procedure cmdNewMail.Click
		Thisform.olecontrol1.NewMessage()
	Endproc

	Procedure cmdNewTask.Click
		Thisform.olecontrol1.NewTask()
	Endproc

	Procedure cmdNewContact.Click
		Thisform.olecontrol1.NewContact()
	Endproc

	Procedure cmdNewAppointment.Click
		Thisform.olecontrol1.NewAppointment()
	Endproc

	Procedure cmdCalendar.Click
		Thisform.olecontrol1.Folder = "CALENDAR"
		Thisform.Caption = "OutLook Calendar"
		Thisform.Refresh()
	Endproc

	Procedure cmdInBox.Click
		Thisform.olecontrol1.Folder = "INBOX"
		Thisform.Caption = "OutLook InBox"
		Thisform.Refresh()
	Endproc

	Procedure cmdSent.Click
		Thisform.olecontrol1.Folder = "SENT ITEMS"
		Thisform.Caption = "OutLook Sent Items"
		Thisform.Refresh()
	Endproc

	Procedure cmdContact.Click
		Thisform.olecontrol1.Folder = "CONTACTS"
		Thisform.Caption = "OutLook Address Book"
		Thisform.Refresh()
	Endproc
	Procedure cmdSendandReceive.Click
		Thisform.olecontrol1.SendAndReceive()
	Endproc

	Procedure olecontrol1.Init
		This.Folder = "InBox"
	Endproc

Enddefine


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thanks for the reply Mike :)

Soykan OEZCELIK
 
Outlook security does not trigger the aggrivating pop up that clickyes and other methods get around with the above code when running cmdSendandReceive but does trigger with the normal automation code below on my machine.

o=createobject("outlook.application")
oitem=o.createitem(0)
oitem.subject=csubject
oitem.to=cemailadd
oitem.bcc="emailname@emailaddress"
oitem.body=CBODY
oitem.attachments.add(&COBFILENAME)
oitem.send
o=.null.

Just wondering if this ole control on an invisible form or something could be used to get completely around the outlook security?

wjwjr
 
White605

The method I described uses the Outlook activex on a form, the method you describe uses Outlook as a COM. In the first example, it used more for a developer to build an interface around Outlook. In you case it is more a hidden way of using Outlook to send e-mails without an interface. Different uses for different purposes, with obviously different results. Perhaps if you use the .Display() method of you message and let the user hit the send button, the message would be avoided. I cannot test this on my current system.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Thats what i was thinking, but,
at one point of using the "com" method the email would go to the outbox and sit there until the next send. If it was left in that state and then the automation code called the click event cmdsendreceive in the activex which was hidden on the form it might go out around the security without the clickyes or redemption.
wjwjr
 
White605.

Or...Don't use Outlook at all. Switch to something like CDO which does not use MAPI as an engine (Which is where the message stems from).

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top