Re: Attachments to MAPI Message
- From: "Randy Birch" <rgb_removethis@xxxxxxxx>
- Date: Mon, 16 May 2005 20:16:30 -0400
<g> I believe it's the same guy responsible for InputBox
(http://vbnet.mvps.org/code/helpers/inputbox.htm)
--
Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/
----------------------------------------------------------------------------
Read. Decide. Sign the petition to Microsoft.
http://classicvb.org/petition/
----------------------------------------------------------------------------
"Peter Schoots" <PeterSchoots@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7C9ED62E-1DE8-427E-9CF0-BF3124F1C70C@xxxxxxxxxxxxxxxx
: Randy,
:
: Thanks very much for your advice. I would have never figured this out.
The
: concept of position holders for attachments and adding spaces at the
: beginning of the text is completely alien. Actually, I now understand
that
: you can use any position within the message text as a position holder.
So
: adding spaces is kind of clever. Whoever designed this must have been
from
: another planet though.
:
: Thanks again.
:
: peter Schoots
:
: "Randy Birch" wrote:
:
: > Are you adding one space to the message body for each attachment? This
is
: > required for some reason - act's sort of like a placeholder.
: >
: > mapi.MsgNoteText = space$(numberofattachments) & msg
: >
: > Do this before assigning the attachments to the message. You have to
: > increment both the AttachmentIndex and AttachmentPosition values, in
: > addition to specifying the AttachmentType. The demo below can be dropped
: > onto a form and called as:
: >
: > MapiSendMultipleAttachments "d:\file1.zip", "d:\file2.zip"
: >
: >
: > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
: > ' Copyright B)1996-2005 VBnet, Randy Birch, All Rights Reserved.
: > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
: > ' You are free to use this code within your own applications,
: > ' but you are expressly forbidden from selling or otherwise
: > ' distributing this source code without prior written consent.
: > ' This includes both posting free demo projects made from this
: > ' code as well as reproducing the code in text or html format.
: > ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
: >
: >
: > Private Function MapiSendMultipleAttachments(Optional sAttachFile1 As
: > String, _
: > Optional sAttachFile2 As
: > String, _
: > Optional sAttachFile3 As
: > String) As Boolean
: >
: > On Local Error GoTo mapisend_error
: >
: > 'parameters for a MAPI session
: > With MAPISession1
: >
: > 'specifies whether a new mail session should be
: > 'established, even if a valid session currently
: > 'exists.
: > .NewSession = False
: >
: > 'specifies whether or not a dialog box
: > 'is provided for sign-on.
: > .LogonUI = False
: >
: > 'the account user name or the Profile to be used
: > 'to establish a session. On systems with Exchange
: > 'or Outlook installed, this sets the Profile to
: > 'be used when establishing a session. Profiles
: > 'include the actual user name and password to be
: > 'used. On computers that use MS Mail, this contains
: > 'the name of the user account desired for sign-on
: > 'or sign-off. If the LogonUI property is True, an
: > 'empty string in the UserName property indicates
: > 'that a sign-on dialog box with an empty name field
: > 'should be generated. The default is an empty string.
: >
: > '---------------------------------------------
: > '.UserName = "whatever"
: > '---------------------------------------------
: >
: > 'specifies if new messages should be downloaded
: > 'from the mail server for the designated user.
: > .DownLoadMail = False
: >
: > 'the account password associated with the UserName
: > 'property. The Exchange/Outlook rues above apply.
: > 'On computers that have MSl installed, an empty
: > 'string in this property indicates that a sign-on
: > 'dialog box with an empty password field should
: > 'be generated. The default is an empty string.
: > '.Password = "complete if not using a profile"
: > .SignOn
: >
: > End With
: >
: >
: > If MAPISession1.SessionID <> 0 Then
: >
: > 'parameters for the message
: > With MAPIMessages1
: >
: > 'assign the session ID to the message object
: > .SessionID = MAPISession1.SessionID
: >
: > 'clears all the components of the compose buffer
: > 'and sets the MsgIndex property to -1.
: > .Compose
: >
: > 'the MsgIndex property is called the currently
: > 'indexed message. When this index is changed,
: > 'all of the other message properties change to
: > 'reflect the characteristics of the indexed
: > 'message. A value of -1 signifies a message
: > 'being built in the compose buffer - in other
: > 'words, an outgoing message.
: > .MsgIndex = -1
: >
: > 'subject line for the currently indexed message as
: > 'displayed in the message header. Not available at
: > 'design time and is read-only unless MsgIndex is
: > 'set to -1. MsgSubject is limited to 64 characters,
: > 'including the terminating Null character added.
: > .MsgSubject = "MAPI Demo of Multiple Attachments to a Single
: > Recipient"
: >
: > 'set the recipient index, name, address and type
: >
: > 'only one recipient (index 0)
: > .RecipIndex = 0
: >
: > 'name and email of the currently indexed recipient.
: > .RecipDisplayName = "Bob at work"
: > .RecipAddress = "bob@xxxxxxxx"
: >
: > 'which field does this recipient go in? Possible values are:
: > 'mapOrigList 0 The message originator.
: > 'mapToList 1 The recipient is a primary recipient.
: > 'mapCcList 2 The recipient is a copy recipient.
: > 'mapBccList 3 The recipient is a blind copy recipient.
: > .RecipType = mapToList
: >
: >
: > 'The body of the message.
: > '*** NOTE ***
: > '*** The value 3 is passed to the Space() function in the ***
: > '*** next line because there are up to three attachments to
add.
: > ***
: > '*** These spaces act as placeholders for the attachments. ***
: > '*** NOTE ***
: > .MsgNoteText = Space$(3) & vbCrLf & _
: > "As a messaging architecture, MAPI " & _
: > "enables multiple applications " & _
: > "to interact with multiple messaging " & _
: > "systems across a variety " & _
: > "of hardware platforms." & vbCrLf & vbCrLf & _
: > "This message will have up to three " & _
: > "attachments depending on the files " & _
: > "passed to MapiSendMultipleAttachments."
: >
: > 'set the attachment indexes, positions and filenames
: > If Len(sAttachFile1) > 0 Then
: > .AttachmentIndex = 0
: > .AttachmentPosition = 0
: > .AttachmentType = mapData
: > .AttachmentPathName = sAttachFile1
: > End If
: >
: > If Len(sAttachFile2) > 0 Then
: > .AttachmentIndex = 1
: > .AttachmentPosition = 1
: > .AttachmentType = mapData
: > .AttachmentPathName = sAttachFile2
: > End If
: >
: > If Len(sAttachFile3) > 0 Then
: > .AttachmentIndex = 2
: > .AttachmentPosition = 2
: > .AttachmentType = mapData
: > .AttachmentPathName = sAttachFile3
: > End If
: >
: > 'send it!
: > '
: > 'By specifying True the email client will
: > 'display the ready-to-send email as composed.
: > 'False is the default setting (send immediately).
: > '
: > 'If True is specified and the user makes
: > 'changes in the message before sending,
: > 'the changes are sent but the mapi compose
: > 'buffer is not notified of the change to
: > 'the message.
: >
: > .Send True 'False '<change to false to send immediately
: >
: > DoEvents
: >
: > 'end the session and sign user off
: > MAPISession1.SignOff
: >
: > End With
: >
: >
: > End If
: >
: > MapiSendMultipleAttachments = True
: >
: >
: > Exit Function
: >
: > mapisend_error:
: >
: > MsgBox Err.Number & vbTab & Err.Description
: > If MAPISession1.SessionID Then MAPISession1.SignOff
: >
: > MapiSendMultipleAttachments = False
: >
: > End Function
: >
: >
: > --
: >
: > Randy Birch
: > MS MVP Visual Basic
: > http://vbnet.mvps.org/
:
> ----------------------------------------------------------------------------
: > Read. Decide. Sign the petition to Microsoft.
: > http://classicvb.org/petition/
:
> ----------------------------------------------------------------------------
: >
: >
: >
: > "Peter Schoots" <PeterSchoots@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
message
: > news:59D6D8B9-EF45-4D71-9742-5C21DCBC8498@xxxxxxxxxxxxxxxx
: > :I have this baffling problem that when I have 2 attachments to a MAPI
: > Message
: > : I get a message "Unspecified error etc.." while a message with one
: > attachment
: > : works without a problem. The attachmentindices are correct (0 and 1)
and
: > : AttachmentPathNames are correct.
: > : I am using Outlook 2003 as the Mail Client.
: > : I am using VB 6.0.
: > :
: > : Thanks for any help.
: > :
: > : Peter Schoots
: >
: >
.
- References:
- Attachments to MAPI Message
- From: Peter Schoots
- Re: Attachments to MAPI Message
- From: Randy Birch
- Re: Attachments to MAPI Message
- From: Peter Schoots
- Attachments to MAPI Message
- Prev by Date: Re: Attachments to MAPI Message
- Next by Date: Inet control - Send vars via post ( & sign issue)
- Previous by thread: Re: Attachments to MAPI Message
- Next by thread: Inet control - Send vars via post ( & sign issue)
- Index(es):
Relevant Pages
|