Sub insuremail()
' User Permissions
If Application.UserName = "Edward Selkov" Then ActiveSheet.UnProTect "EDS" Else GoTo xit
' Set Output
' If MsgBox("Send Email?", vbYesNo + vbQuestion, "Email") = vbYes
'---------------------------------------------------------------------------------------
Email:
' Get/Create an Outlook instance
On Error Resume Next
Set objOutlookApp = GetObject(, "Outlook.Application")
If Err Then
Set objOutlookApp = CreateObject("Outlook.Application")
IsOutlookCreated = True
End If
On Error GoTo 0
' Create a new email, fill it and send
With objOutlookApp.CreateItem(0)
' Set HTML format
.BodyFormat = 2
'Default lines
sname = ""
eml = "wmnce@cfs.com"
bccl = ""
' Email Signature
ssig = vbLf & vbLf & vbLf _
& "Regards" _
& sname _
& vbLf _
& "Contracts Team" _
& vbLf
ssig = Replace(ssig, vbLf, Chr(60) & "br" & Chr(62))
' Concatenate all parts for HtmlBody
sText = shtmlheader & ssig
' Insert sText into HtmlBody
.htmlbody = sText & "<IMG src=""C:\Users\edward.selkov\AppData\Roaming\Microsoft\Signatures\EDS_files\small.png"">"
'*******************************************************************************************************
'Specify email recipients, subject, etc:
.To = ema
Const Behalf = " wmnce@cfs.com " ' <-- Name to send on behalf of Exchange profile/account
'.Cc = "carboncopy@..."
.Bcc = bccl
.Subject = inltr & tdd & " -- For -- " & vnd
.SentOnBehalfOfName = Behalf
' .send '<-- Directly send out this email, use .Display instead for the debugging only
.display
End With
GoTo res
xit:
'Prevent memory leakage
Set objAccount = Nothing
ema = ""
vnd = ""
shtmlheader = ""
' Quit Outlook instance if it was created by this code
If IsOutlookCreated Then
objOutlookApp.Quit
Set objOutlookApp = Nothing
End If
' Close Workbook
' Application.DisplayAlerts = False
' Workbooks("Account Representitive").Close (False)
' Application.DisplayAlerts = True
End Sub