AnsweredAssumed Answered

vrf Sending email with outlook from VEE

Question asked by kevin.hasselquist on Jun 17, 2003
Here we go- I haven't tried it of course, but it sounds good...

-----Original Message-----
From: ext Richard Wise [mailto:Richard.Wise@raymarine.com]
Sent: 14 May, 2003 7:09 AM
To: VEE vrf
Subject: [vrf] RE: Sending email with outlook from VEE


Put this into a formula box to send the keystroke 'y' when the warning appears - it's not pretty, but it will dismiss the dialog box...

set s = CreateObject("WScript.Shell");
s.sendkeys("y");

-----Original Message-----
From: KOHLER,ADAM (A-Scotland,ex1) [mailto:adam_kohler@agilent.com]
Sent: 14 May 2003 09:35
To: VEE vrf
Subject: [vrf] RE: Sending email with outlook from VEE


Shawn,

Thanks for this.  Well it does send the email but that outlook pop-up warning of a possible virus still appears and stops the program until you press Yes.  If you press NO then the program crashes.

Adam Kohler
Software Test
EPSG
Agilent Technologies
Scotland

tel net 313 2485
t +44 131 331 7485
e adam_kohler@agilent.com

-----Original Message-----
From: Shawn Fessenden [mailto:shawn@testech-ltd.com]
Sent: Wed 14 May 2003 09:01
To: VEE vrf
Subject: [vrf] RE: Sending email with outlook from VEE


Adam -

Yes, Kevyn is correct. MAPI is the underlying Messaging API. If you have
almost any mail client installed at all, you'll be able to access MAPI. Look
under ActiveX Automation References for Microsoft CDO 1.x Library or
Microsoft CDO for Exchange. CDO stands for "Collaboration Data Objects". The
advantage is you loose the Outlook dependency.

All respect to Mark, but I'd kind of advise staying away from the MAPI
control and the VEE example program. It's too crowded and confusing. All you
need is a reference to a MAPI session and you can do just about any kind of
emailing you want with just a few statements. There's no need for a MAPI
control and a message control, you don't have to fill everything out, etc.

Enter these statements in a Formula object (or open the attached):

Set s = CreateObject("MAPI.Session");
s.Logon;
Set m = s.Outbox.Messages.Add("RE: Test", "Yup, it works.");
m.Recipients.Add("Shawn", "SMTP:shawn@testech-ltd.com", 1);
m.Send;
s.DeliverNow;
s.Logoff;

Stick "s" and "m" pins on the right side, press Ctrl-G and, provided you're
connected to the internet, "you've sent mail". That's all there is too it.

The Subject and body of the message are the "Subject" and "Text" properties
of the Message object, respectively. The only thing that's a little funky is
the Add method of the Recipients collection. You have to prefix the
addressee with "SMTP:", and the third parameter (Type) is:

CdoTo  = 1
CdoCc  = 2
CdoBcc = 3

For some reason, VEE can't find these named constants (I've no idea why).

To avoid the "logon" dialog, all you have to do is logon once and get the
Name property of the Session object. Save it somewhere, then logon with:

s.Logon(sName);

The object model is very similar to Outlook's. I just converted a load of VB
stuff from Outlook to MAPI and it was a snap. It's very easy to work with
and I don't think you'll have much of a hard time. Here's a few VB things
you can adapt to VEE to get you started. This is from Form_Load:

' Verify MAPI.
lErr = RegOpenKeyEx(HKCR, "MAPI.Session", 0, KEY_READ, hKey)
If lErr <> 0 Then
  Call MsgBox("Windows Messaging is not installed", vbOKOnly + vbCritical,
"MAPI Error")
  Unload Me
  Exit Sub
End If
Call RegCloseKey(hKey)

' Get default profile.
sProfile = GetSetting(App.Title, "Settings", "Profile")

' Create session & log on.
Set m_session = New MAPI.Session
Call m_session.Logon(sProfile)

Here's that bit about saving the profile name (from Form_Unload):

' Save profile.
Call SaveSetting(App.Title, "Settings", "Profile", m_session.Name)

' Logoff & kill session.
Call m_session.Logoff
Set m_session = Nothing

Using MAPI is just as easy:

' Get Inbox & messages.
Set oInbox = m_session.Inbox
Set oMsgs = oInbox.Messages

You can set up a mail profile specifically for your test program - you don't
have to use one that's already there.
-SHAWN-

---
You are currently subscribed to vrf as: Richard.Wise@raymarine.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@it.lists.it.agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

---
You are currently subscribed to vrf as: Kevin.Hasselquist@nokia.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@it.lists.it.agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

---
You are currently subscribed to vrf as: rsb@soco.agilent.com
To subscribe send a blank email to "join-vrf@it.lists.it.agilent.com".
To unsubscribe send a blank email to "leave-vrf@it.lists.it.agilent.com".
To send messages to this mailing list,  email "vrf@it.lists.it.agilent.com". 
If you need help with the mailing list send a message to "owner-vrf@it.lists.it.agilent.com".

Outcomes