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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

e-mail File Attachments 2

Status
Not open for further replies.

maxflitom

Programmer
Aug 26, 2002
70
US
Hello Tek-Tips

I have searched the archives unsuccessfully. I wish to add the ability to attach files to emails sent utilizing my code below:

**General Declaration Section**

Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Dim strAddress As String
Dim strOpen As Long
strAddress = "mailto:someone@email.com?"
strOpen = ShellExecute(Me.hwnd, "Open", strAddress, "", "", vbNormalFocus)

I want the abliity to open the default e-mail client and have the user confirm the message before sending.

Any suggestions will be greatly appreciated.

Tom

Tom (maxflitom)
 
Whilst it is possible to use the mailto URL to indicate that you want to send attachments, what actually happens is completely on the application that ultimately resolves the URL - typically, for mailto, your default e-mail client. It's worth pointing out, for example, that the Microsoft e-mail client's only recognise the recipient, cc, bcc, subject and body headers from the mailto URL. It is also worth pointing out that a number of email clients don't support cc or bcc (heck, only a few years ago Microsoft's premier email client only supported the recipient header/value)

>I want the abliity to open the default e-mail client and have the user confirm the message before sending

This is required behaviour of any mailto URL resolver: it must display, and request confirmation of, all the headers and their assigned values.

So, using mailto will address all you requirements except adding attachments, which would be dependant specific email clients

If you absolutely must automate the addition of attachments (rather than letting the user review the mail and add the attachment themselves) then you may need to look at different ways to send the e-mail. And here's a starting point or two:

The common MS technologies for doing this are:

CDO 1.2.x - essentially a simplified scripting wrapper for MAPI, so requires that a MAPI client has been installed (eg Outlook) and Exchange Server
CDO for Windows 2000/CDO for Exchange Server 2000 - requires that your platform is at least Windows 2000, and that you have visibility of an SMTP server. Unlike CDO 1.2.x, it is not MAPI-based and does not require Exchange Server
CDONTS - leverages the SMTP server included in IIS. Not MAPI-based. Requires NT Server and IIS
MAPI - Microsoft's primary mail application programming interface. Requires Exchange Server
Simple MAPI - limited, simplified version of MAPI (more accurately, the original version of MAPI, renamed as Simple MAPI when the more complex version was being conceived)

(The MAPI controls available for VB are basically a wrapper for Simple MAPI)

Note that some other email programs provide MAPI servers (eg Eudora), which can often replace the requirement for Exchange Server for any of the MAPI-based technologies mentioned above

There is a comparison of CDO 1.2.1 and CDONTS here:
 
>>CDO 1.2.x - essentially a simplified scripting wrapper for MAPI, so requires that a MAPI client has been installed (eg Outlook) and Exchange Server<<

Only an Extended MAPI client such as Outlook is needed. CDO 1.21 doesn't require Exchange Server. I have noticed one or two &quot;obscure&quot; things that don't work as expected when Outlook is in Internet-Only mode but nothing that would affect attachments.

>>MAPI - Microsoft's primary mail application programming interface. Requires Exchange Server<<

Doesn't need Exchange Server, just an Extended MAPI client or a Simple MAPI client plus the Windows Messaging Subsystem if running under W9x.

When using VB you have to call the special &quot;B&quot; functions in mapi32.dll.

Paul Bent
Northwind IT Systems
 
Well, kind of. You get minimal MAPI support. Wait one...yes, here we are:
If you install Outlook in Internet Only Mode (or you have the Windows Messaging System installed), you can indeed get away with using a minimal set of MAPI functionality allowing some use of CDO 1.2.1, MAPI, and all of Simple MAPI (and, therefore, VB's MAPI controls). However, Microsoft claim that they do not support this. As long as you just want minimal functionality (and I'd agree that is what the original post suggests) then this is probably fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top