Wrox Programmer Forums
|
Beginning VB 6 For coders who are new to Visual Basic, working in VB version 6 (not .NET).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 4th, 2008, 04:41 AM
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Attachment error ...

hi....
i did this form for sending emails...
the form consists of:
text boxex:
from, to , subject , attachment...
buttons:
send , forward, ...etc


when i fill the info and send the email it will not go , can someone help me with the coding....i get the error with the attachment ....
when i use the browse button to choose the attached file and then click the send button , after few seconds i get
runtime error'32002':
unspecified failure has occured

when i debug it takes me to this part of code:
Code:
MAPIMessages1.Send
but when i remove this part of code in the send button:
Code:
MAPIMessages1.AttachmentPathName = txtAttach.Text
it will send the email..
can some one help me with this... just new in viisual basic

this is my code:

Code:
Option Explicit

Dim lPosition As Long


Private Sub cmdBack_Click()


If lPosition > 0 Then

lPosition = lPosition – 1



MAPIMessages1.MsgIndex = lPosition

txtFrom.Text = MAPIMessages1.MsgOrigDisplayName

txtTo.Text = MAPIMessages1.RecipDisplayName

txtSubject.Text = MAPIMessages1.MsgSubject

txtMessage.Text = MAPIMessages1.MsgNoteText

txtAttach.Text=MAPIMessages1.AttachmentPathName  


End If

End Sub

Private Sub cmdBrowse_Click()

Dim sFilenames() As String
Dim i As Integer

On Local Error GoTo Err_Cancel

With cmDialog
.FileName = ""
.CancelError = True
.Filter = "All Files (*.*)|*.*|HTML Files (*.htm;*.html;*.shtml)|*.htm;*.html;*.shtml|Images (*.bmp;*.jpg;*.gif)|*.bmp;*.jpg;*.gif"
.FilterIndex = 1
.DialogTitle = "Select File Attachment(s)"
.MaxFileSize = &H7FFF
.Flags = &H4 Or &H800 Or &H40000 Or &H200 Or &H80000
.ShowOpen
' get the selected name(s)
sFilenames = Split(.FileName, vbNullChar)
End With

If UBound(sFilenames) = 0 Then
If txtAttach.Text = "" Then
txtAttach.Text = sFilenames(0)
Else
txtAttach.Text = txtAttach.Text & ";" & sFilenames(0)
End If
ElseIf UBound(sFilenames) > 0 Then
If Right$(sFilenames(0), 1) <> "\" Then sFilenames(0) = sFilenames(0) & "\"
For i = 1 To UBound(sFilenames)
If txtAttach.Text = "" Then
txtAttach.Text = sFilenames(0) & sFilenames(i)
Else
txtAttach.Text = txtAttach.Text & ";" & sFilenames(0) & sFilenames(i)
End If
Next
Else
Exit Sub
End If

Err_Cancel:
End Sub

Private Sub cmdClose_Click()
MAPISession1.SignOff

Unload Me


End Sub

Private Sub cmdForward_Click()


If lPosition < MAPIMessages1.MsgCount Then

lPosition = lPosition + 1



MAPIMessages1.MsgIndex = lPosition

txtFrom.Text = MAPIMessages1.MsgOrigDisplayName

txtTo.Text = MAPIMessages1.RecipDisplayName

txtSubject.Text = MAPIMessages1.MsgSubject

txtMessage.Text = MAPIMessages1.MsgNoteText


End If

End Sub

Private Sub cmdSend_Click()
'Start by telling the control that we are composing an e-mail

MAPIMessages1.Compose



MAPIMessages1.RecipDisplayName = txtTo.Text

MAPIMessages1.MsgSubject = txtSubject.Text

MAPIMessages1.MsgNoteText = txtMessage.Text
MAPIMessages1.AttachmentPathName = txtAttach.Text

MAPIMessages1.ResolveName



MAPIMessages1.Send


End Sub

Private Sub Form_Load()
'Sign on to the MAPI Session

MAPISession1.SignOn

MAPIMessages1.SessionID = MAPISession1.SessionID

MAPIMessages1.Fetch


End Sub
one more thing please
if i want to send to more than one person how can i do this?
because it only sends to one person
thank you


 
Old March 4th, 2008, 07:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

did you try google for that error?? what do you find?

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old March 4th, 2008, 05:17 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Separate the email addresses with semi colons to send to more than one address.

(BTW, Use your shift key. It makes posts easier to
read. capitalize “I.” Capitalize the first letter
of new sentences.)

Try sending the contents of the text box to the debug
window, then post here the result of that.
 
Old March 5th, 2008, 01:43 AM
Registered User
 
Join Date: Mar 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi i checked in google about the error i did not find something that helps me ...

can some one give me a suggestion?

 
Old March 5th, 2008, 07:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there..

My first hit when i try google with "mapi 32002" was this page http://support.microsoft.com/?scid=k...86148&x=16&y=8.

This didn't solve your problem????

Also the second hit http://support.microsoft.com/?scid=k...52708&x=4&y=17 is about multiple recipients...

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old March 5th, 2008, 03:27 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Quote:
quote:Originally posted by nawaray
 h[capitalize]i[use a period at the end of a sentence] i[capitalize] checked in g[capitalize]oogle about the error[use a period at the end of a sentence] i[capitalize] did not find something that helps me ...

c[capitalize]an some one give me a suggestion?

[u]H</u>i[u].</u> [u]I</u> checked in [u]G</u>oogle about the error[u].</u> [u]I</u> did not find something that helps me...

[u]C</u>an some one give me a suggestion?
LookNawaraythisisntablog....

This is a site where professionals help professionals, and others.

Please show respect for those who would help you—use punctuation. Use your shift key to capitalize the 1st letter of sentences, and the pronoun, “I.”





Similar Threads
Thread Thread Starter Forum Replies Last Post
Email Attachment rat07 PHP How-To 1 June 19th, 2007 01:27 PM
error sending email with attachment using CDO archanahs Classic ASP Professional 1 May 25th, 2006 08:16 AM
Attachment alannoble26 Excel VBA 3 January 9th, 2006 01:47 PM
mail-attachment sureshdev786 General .NET 0 December 27th, 2004 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.