Option Explicit
Private Sub btnCancel_Click()
Unload Me
End Sub
Private Sub btnSubmit_Click()
Dim oFSO As Object
Dim oFS As Object
Dim MailMsg As Outlook.MailItem
Dim rootPath As String
Dim templateFile As String
Dim sText As String
Dim sbody As String
Set MailMsg = GetCurrentItem
Set oFSO = CreateObject("Scripting.FileSystemObject")
sbody = MailMsg.HTMLBody
rootPath = "\\servername\networkshare\Outlook app VBscript\Prealert template\"
templateFile = ""
'path = rootPath + templateFile + ".html"
If ArrivalOBtn.Value Then
templateFile = "Arrival_Confirmation"
MailMsg.Subject = Replace(MailMsg.Subject, "Pre alert", "Arrival confirmation", , , vbTextCompare)
MailMsg.Subject = Replace(MailMsg.Subject, "RE:", "", , , vbTextCompare)
ElseIf DAPOBtn.Value Then
templateFile = IIf(CheckBox1, "Arrival_Confirmation_DAP", "Arrival_Confirmation_DAP_2")
MailMsg.Subject = Replace(MailMsg.Subject, "Pre alert", "Arrival confirmation", , , vbTextCompare)
MailMsg.Subject = Replace(MailMsg.Subject, "RE:", "", , , vbTextCompare)
ElseIf DelieveryOBtn.Value Then
templateFile = IIf(CheckBox1, "Delivery_Confirmation", "Delivery_Confirmation_2")
MailMsg.Subject = Replace(MailMsg.Subject, "Arrival confirmation", "Delivery confirmation", , , vbTextCompare)
MailMsg.Subject = Replace(MailMsg.Subject, "RE:", "", , , vbTextCompare)
ElseIf BrokerOBtn.Value Then
templateFile = "Broker_requested"
MailMsg.Subject = Replace(MailMsg.Subject, "Arrival confirmation", "Delivery confirmation", , , vbTextCompare)
MailMsg.Subject = Replace(MailMsg.Subject, "RE:", "", , , vbTextCompare)
End If
Set oFS = oFSO.OpenTextFile(rootPath + templateFile + ".html")
sText = oFS.ReadAll()
sText = Replace(sText, "<contact>", tbContact.Value, , vbTextCompare)
sText = Replace(sText, "<ata>", tbATA.Value, , vbTextCompare)
MailMsg.BodyFormat = olFormatHTML
MailMsg.HTMLBody = "<body font-siz=11pt>" & sText & sbody & "</body>"
If Dir(rootPath + templateFile + ".gif") <> "" Then
MailMsg.Attachments.Add rootPath + templateFile + ".gif", olByValue, 0, "test"
End If
Call removerecipi(MailMsg, "Danoffice")
Set oFS = Nothing
Set oFSO = Nothing
Set MailItem = Nothing
Unload Me
End Sub