AYUDA PLEASE con VISUAL BASIC, es urgente!!!!!!!
Publicado: Sab Dic 14, 2002 4:53 pm
Hola, resulta que mi profe nos ha hecho hacer un formulario de Visual Basic, la función del qual es enviar mails ya archivos adjuntos junto al mail. El programa se basa en el outlook, pero no hace falta entrar en el, para utilizarlo, sino que hace como de puente.Y resulta que me da un fallo, pero no consigo adivinar lo que puede ser y me estoy volviendo loco.Este es el codigo del programa.Si alguien me ayuda se lo agradeceria mucho, ya que el tio ese es capaz de suspenderme solo porque no me va esa práctica. Un saludo y gracias!!!!!!!!!
Private WithEvents mOutlook As Outlook.Application
Private WithEvents Mail As Outlook.MailItem
Private attachment As Outlook.Attachments
________________________
Private Sub cmdcancel_Click()
txtsubject.Text = ""
txtadreça.Text = ""
txtmissatge.Text = ""
mOutlook.Quit
End Sub
________________________
Private Sub cmdenviar_Click()
Set Mail = mOutlook.CreateItem(olMailItem)
Set attachment = Mail.Attachments
Mail.To = txtadreça.Text
'El mail va dirigit a la direcció que correspon al text que hi ha en la textBox
Mail.Subject = txtsubject.Text
Mail.Body = txtmissatge.Text
If (Drive1.Drive + "\") = Dir1.Path Then
Path = Drive1.Drive + "\" + File1.FileName
Else
Path = File1.Path + "\" + File1.FileName
End If
attachment.Add Path, olByValue, 1, "Arxiu adjunt"
attachment.Add Path = Drive1 + "\" + Dir1.Path + "\" + File1.Path & File1.List(File1.ListIndex), olByValue, 1, "Archivo adjunto"
Mail.Send
End Sub
_______________________
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1 = Drive1
End Sub
_____________________________
Private Sub Form_Load()
Set mOutlook = New Outlook.Application
End Sub
__________________________
Private Sub cmdexit_Click()
Unload Me
End Sub
Private WithEvents mOutlook As Outlook.Application
Private WithEvents Mail As Outlook.MailItem
Private attachment As Outlook.Attachments
________________________
Private Sub cmdcancel_Click()
txtsubject.Text = ""
txtadreça.Text = ""
txtmissatge.Text = ""
mOutlook.Quit
End Sub
________________________
Private Sub cmdenviar_Click()
Set Mail = mOutlook.CreateItem(olMailItem)
Set attachment = Mail.Attachments
Mail.To = txtadreça.Text
'El mail va dirigit a la direcció que correspon al text que hi ha en la textBox
Mail.Subject = txtsubject.Text
Mail.Body = txtmissatge.Text
If (Drive1.Drive + "\") = Dir1.Path Then
Path = Drive1.Drive + "\" + File1.FileName
Else
Path = File1.Path + "\" + File1.FileName
End If
attachment.Add Path, olByValue, 1, "Arxiu adjunt"
attachment.Add Path = Drive1 + "\" + Dir1.Path + "\" + File1.Path & File1.List(File1.ListIndex), olByValue, 1, "Archivo adjunto"
Mail.Send
End Sub
_______________________
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
Dir1 = Drive1
End Sub
_____________________________
Private Sub Form_Load()
Set mOutlook = New Outlook.Application
End Sub
__________________________
Private Sub cmdexit_Click()
Unload Me
End Sub