Option
Explicit
Private
Sub
CommandButton1_Click()
Dim
strEmailAdr
As
String
strEmailAdr = InputBox(
"Emailadresse des Empfängers eingeben:"
,
"Mailadresse"
)
If
InStr(1, strEmailAdr,
"@"
, vbBinaryCompare) = 0
Or
InStr(1, strEmailAdr,
"."
, vbBinaryCompare) = 0
Then
MsgBox
""
""
& strEmailAdr &
""
" ist keine Emailadresse!"
& Chr(10) _
&
"Geben Sie eine gültige Emailadresse ein!"
, vbCritical,
"Abbruch..."
Exit
Sub
End
If
ThisDocument.VBProject.VBComponents(
"ThisDocument"
).CodeModule.ReplaceLine 32,
"strEmailAdr = "
""
& strEmailAdr &
""
""
ThisDocument.VBProject.VBComponents(
"ThisDocument"
).CodeModule.DeleteLines 2, 23
With
ThisDocument.CommandButton1
.Width = 0
.Height = 0
.ForeColor = 2
.BackColor = 2
.Enabled =
False
End
With
ThisDocument.Protect wdAllowOnlyReading, , strEmailAdr
ThisDocument.Save
End
Sub
Private
Sub
CommandButton2_Click()
Dim
olApp
As
Outlook.Application, olMail
As
Outlook.MailItem
Dim
olMail
As
Outlook.MailItem
Dim
olRun
As
Boolean
Dim
strEmailAdr
As
String
strEmailAdr =
""
On
Error
Resume
Next
If
strEmailAdr =
""
Then
MsgBox
"Wegen fehlender Emailadresse kann keine Antwortmail versandt werden!"
, vbCritical,
"Abbruch..."
Exit
Sub
End
If
olRun =
True
Set
olApp = GetObject(,
"Outlook.Application"
)
If
Err.Number <> 0
Then
Err.Clear
Set
olApp = CreateObject(
"Outlook.Application"
): DoEvents
Start = Timer
While
Timer < Start + 5
DoEvents
Wend
olRun =
False
End
If
Set
olMail = olApp.CreateItem(0)
With
olMail
.Recipients.Add strEmailAdr
.Subject =
"Rückmeldung"
.body =
"Ihre Mail bezüglich der ausstehenden Lieferung ist hier eingegangen und wurde bearbeitet."
.send
End
With
Set
olMail =
Nothing
If
olRun =
False
Then
olApp.Quit: DoEvents
Start = Timer
While
Timer < Start + 5
DoEvents
Wend
End
If
Set
olApp =
Nothing
End
Sub