Consulting

Results 1 to 4 of 4

Thread: vba script to open emails via a form

  1. #1

    Question vba script to open emails via a form

    Hi everybody,

    I'm quite new in programming vba for outlook, so I helped myself with some Excel vba code but it doesn't really work out. I am stumped. Please help me.

    This is how it's supposed to work:
    I have a form in which I insert the data, press ENTER and the code opens a specific email, which is already in the Code.

    Here comes the catch:
    The Emails are gonna be displayed and not sent (what works surprisingly)

    And here is the Code: (It's a bit shortend)

    Private Sub OptionButton_Absage_Click()
    ComboBox1.Clear
    With ComboBox1
    .AddItem "Absage auf Initiativbewerbung"
    .AddItem "Absage nach Erstgespräch"
    .AddItem "Absage nach Zweitgespräch"
    .AddItem "Absage nach Gespräch auf Messe"
    .AddItem "Absage nach Anzeigenschaltung"
    .AddItem "Absage an Patentanwaltskandidaten"
    .AddItem "Absage auf Englisch"
    End With
    End Sub

    Private Sub OptionButton_Eingangsbestaetigung_Click()
    ComboBox1.Clear
    With ComboBox1
    .AddItem "Eingangsbestätigung"
    .AddItem "Anforderung fehlender Unterlagen allgemein"
    .AddItem "Anforderung Abiturzeugnis"
    End With
    End Sub

    Private Sub OptionButton_sonstiges_Click()
    ComboBox1.Clear
    With ComboBox1
    .AddItem "Anschreiben ON HOLD Kandidaten"
    .AddItem "Zwischenbescheid an Bewerber"
    .AddItem "Nachfassen beim Partner"
    End With
    End Sub

    Private Sub cmd_Enter_Click()

    If Me.OptionButton_Frau.Value = True Then
    Call email
    Unload Me
    End If
    End Sub

    Public Sub Email_Outlook()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strbody As String
    Dim SigString As String
    Dim Signature As String
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    strbody = "<FONT face=""Trebuchet MS"" size=2> " & _
    "Text"

    On Error Resume Next
    With OutMail
    .To = Me.txt_Email.Value
    .CC = ""
    .BCC = ""
    .Subject = "Ihre Bewerbung bei Bird & Bird LLP"
    .HTMLBody = strbody
    .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub

  2. #2
    VBAX Mentor skatonni's Avatar
    Joined
    Jun 2006
    Posts
    347
    Location
    I do not know what the question is but maybe you want to use

    Call Email_Outlook rather than Call email

  3. #3
    No that wasn't the question and it was a mistake I did because I shortend.

    So thanks for that.

    Here is the question: After filling data in the form, there should pop up an email. The user should be able to change the email and send it.

    But it doesn't work. The Email is not displayed. On the other hand, ".send" instead of ".display" works.

  4. #4
    This is the part which doesn't work:

    If Me.OptionButton_Frau.Value = True Then
    Call email_outlook
    Unload Me
    End If
    End Sub

    or this:

    Public Sub Email_Outlook()
    Dim OutApp As Outlook.Application
    Dim OutMail As Outlook.MailItem
    Dim strbody As String
    Dim SigString As String
    Dim Signature As String
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    strbody = "<FONT face=""Trebuchet MS"" size=2> " & _
    "Text"

    On Error Resume Next
    With OutMail
    .To = Me.txt_Email.Value
    .CC = ""
    .BCC = ""
    .Subject = "Ihre Bewerbung bei Bird & Bird LLP"
    .HTMLBody = strbody
    .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •