|
-
Oct 27th, 2000, 10:40 AM
#1
Thread Starter
Addicted Member
Hello,
I'm trying to attach a file to an email. Does anyone know hoe to do this? Currently I'm getting run-time error 32002. The program stops at this line: (MAPIMessages1.Send True) Here's the coding (Any Ideas?):
'
MAPISession1.SignOn ' log into MAPI server
MAPIMessages1.SessionID = MAPISession1.SessionID
'
MAPIMessages1.Compose ' clear buffer
MAPIMessages1.RecipDisplayName = "[email protected]"
MAPIMessages1.MsgSubject = "User's CONFIG.SYS File"
MAPIMessages1.MsgNoteText = "Here is the CONFIG.SYS File" + Chr(13) + " "
'
MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText)
MAPIMessages1.AttachmentType = mapData
MAPIMessages1.AttachmentName = "System Configuration File"
MAPIMessages1.AttachmentPathName = "C:\CONFIG.SYS"
'
MAPIMessages1.Send True 'send it
'
MAPISession1.SignOff ' exit MAPI server
'
Thanks
'
212 will lead you to the truth
-
Oct 27th, 2000, 10:51 AM
#2
Fanatic Member
Looks like you are missing this line.
MAPIMessages1.RecipAddress = "[email protected]"
-
Oct 27th, 2000, 10:53 AM
#3
Member
Modified, from the VB6 Samples:
Public Function Send(ByVal RecipAddress As String, _
ByVal MsgSubject As String, _
ByVal MsgNoteText As String, _
ByVal AttachmentPathName As String) As String
'Startet die EMail.App zum versenden einer Mail
'Quelle: VB6-Beispiel 'PRJMAPI.VBP'
Dim curStep As Integer 'zum Lokalisieren man evt. Fehler
On Error GoTo mapiErr
curStep = 1
If mapSess.NewSession Then
Else
With mapSess
.DownLoadMail = False 'Set DownLoadMail to False to prevent immediate download.
curStep = 2
.LogonUI = True 'Use the underlying email system's logon UI.
curStep = 3
.SignOn 'Signon method.
curStep = 4
.NewSession = True
curStep = 5
mapMess.SessionID = .SessionID 'You must set this before continuing.
End With
End If
With mapMess
'Use the Compose method and then invoke the
'Send method. When the optional argument
'is set to True, the underlying mail system's
'form is used. Otherwise, you must create your
'own.
curStep = 6
.Compose
If Len(RecipAddress) Then _
.RecipAddress = RecipAddress
.MsgSubject = MsgSubject
.MsgNoteText = MsgNoteText
.AttachmentPathName = AttachmentPathName
curStep = 7
.Send True
End With
curStep = 8
With mapSess
.SignOff 'Close the session.
.NewSession = False 'Flag for new session.
End With
Unload Me
Exit Function
mapiErr:
Send = ErrorStr(Err, Error$) & " (" & curStep & ")"
Unload Me
Exit Function
End Function
-
Oct 27th, 2000, 12:30 PM
#4
The AttachmentPosition property is zero based, so you should use:
MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText) - 1
-
Oct 27th, 2000, 03:00 PM
#5
Thread Starter
Addicted Member
Sorry guys, I found the answer. When doing an attachment you must specify the index just like an array. Here's the working code:
With MAPIMessages1
.MsgIndex = -1
.Compose
.RecipDisplayName = txtAddressee1.Text
.MsgSubject = txtSubject.Text
.MsgNoteText = rtbMessage.Text
.AttachmentIndex = 0
.AttachmentPathName = AttachmentPath
.AttachmentName = AttachmentName
.AttachmentPosition = 0
.AttachmentType = 2
.ResolveName
.SessionID = MAPISession1.SessionID
.Send 'True
End With
Thanks for the help. I should have posted that I had found the problem sooner. Thanks again.
212 will lead you to the truth
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|