Necesito enviar email con un formulario y lo he echo pero me da un error en ...

Me un error en ; Dim MItem As MailItem 
Private Sub CommandButton2_Click()
Dim myfilepath As String
myfilepath = Application.GetOpenFilename()
TextBox5.Text = myfilepath

End Sub

Private Sub CommandButton3_Click()
If TextBox2.Text = "" Then
MsgBox " Emailadresse schreiben", vbAbortRetryIgnore, "Email Id Bitte"
Exit Sub

End If
'dim outlookapp
Dim Outlookapp As Object
'the mail item is the contents inside a mail
Dim MItem As MailItem
'created outlook app
Set Outlookapp = CreateObject("outlook.Application")
'it will open a new application
Set Outlookapp = New Outlook.Application
'set mail item
Set MItem = Outlookapp.CreateItem(olMailItem)
'error handling
On Error Resume Next
With MItem
.To = Me.TextBox2.Value
.To = Me.TextBox3.Value
.Subject = Me.TextBox3.Value
.Body = Me.ComboBox1.Value & vbCrLf & Me.TextBox4.Value
.Attachments.Add (Me.TextBox5.Value)
.Send

End With
sendEmail.Hide
Call CommandButton4_Click
Call userfr
MsgBox "Die Post wurde gesendet"

End Sub

Private Sub CommandButton4_Click()
With Me
.TextBox1.Text = ""
.TextBox2.Text = ""
.TextBox3.Text = ""
.TextBox4.Text = ""
.TextBox5.Text = ""
.TextBox6.Text = ""
End With
Call UserForm_Initialize
End Sub

Private Sub CommandButton5_Click()
Dim msg As String
msg = "Hilfdatei" & vbCrLf & vbCrLf
msg = msg & "Schreiben Sie den Absender." & vbCrLf & vbCrLf
msg = msg & " Schreiben Sie bitte die richtige E-Mail Adresse des Empfängers" & vbCrLf & vbCrLf
msg = msg & " Begrüßung auswählen." & vbCrLf & vbCrLf
msg = msg & "Betreff schreiben" & vbCrLf & vbCrLf
msg = msg & "Photo einfügen falls gewünscht" & vbCrLf & vbCrLf
msg = msg & "Taste Strg + V um einzufügen, Strg + C zu kopieren" & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf & vbCrLf
msg = msg & "Entwickler Eusebio Guerra Reyes" & vbCrLf & vbCrLf
msg = msg & "Email: [email protected]" & vbCrLf & vbCrLf
note = MsgBox(msg, vbInformation, "Hilfe?")
End Sub

Private Sub CommandButton6_Click()

image_path = Application.GetOpenFilename(FileFilter:="Picture Files (Fichiers image),*.gif;*.jpg;*.jpeg;*.bmp", Title:=" Zeihnung wahlen")
If image_path <> False Then
Me.Image1.Picture = LoadPicture(image_path)
Me.Image1.Visible = True
End If
Var = TextBox1.Text
SavePicture Image1.Picture, ThisWorkbook.Path & "\photos\" & Var & ".jpg"
End Sub

Private Sub CommandButton7_Click()
End
End Sub

Private Sub TextBox1_Change()
Me.ComboBox1.Clear
rec = Me.TextBox1.Text
With Me.ComboBox1
.AddItem " Hallo" & rec
.AddItem "Sehr geehrter Herr"
.AddItem "Sehr geehrte Frau"
.AddItem "Liebe"
.AddItem "Lieber"
End With
End Sub

Private Sub UserForm_Initialize()
Me.ComboBox1.Clear
rec = Me.TextBox1.Text
With Me.ComboBox1
.AddItem " Hallo" & rec
.AddItem "Sehr geehrter Herr"
.AddItem "Sehr geehrte Frau"
.AddItem "Liebe"
.AddItem "Lieber"
End With
End Sub

Respuesta
1

Esa línea se marca con error si no has activado la referencia (VBA) de:

"Microsoft Outlook xx.0 Object Library"

En donde xx es el número equivalente a tu versión de Office.

Abraham Valencia

¡Gracias! Muchas Gracias , ya he corregido el error

Deseo que tengas  Felia Navidad y un prospero año nuevo!

Eusebio

Feliz navidad para ti también :)

Abraham Valencia

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas