cpapplefamily
New Member
- Joined
- Jul 8, 2024
- Messages
- 1
- Office Version
- 365
- Platform
- Windows
I have been using this code for some time and since Outlook added the "New Outlook" this seems to be opening up an old version of outlook resulting in my emails not appearing in the sent folder. This could be a windows thing but it may be possible the code needs to point to a different application. When I toogle back to the "Old Outlook" using the toggle switch in the Outlook application the created and sent email does show.
Here is the code
Here is the code
VBA Code:
'Open Outlook Email
Dim a As Integer
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As String
Dim rngCc1 As Object
Dim rngSubject As String
Dim rngAttach As Range
Dim rngBody As String
Dim sCC As String
Dim emailRng As Range, cl As Range
Dim Signature As String
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
Signature = objMail.HTMLBody
rngSubject = ActiveWorkbook.Sheets("PO Request").Range("C12") & " - Purchase Request - " & ActiveWorkbook.Sheets("PO Request").Range("C3")
rngTo = ActiveWorkbook.Sheets("Email").Range("A1")
rngBody = ActiveWorkbook.Sheets("Email").Range("A2")
Set emailRng = Worksheets("PO Request").Range("C17:C19")
For Each cl In emailRng
sCC = sCC & ";" & cl.Value
Next
With objMail
.Display
.To = rngTo
.CC = sCC
.Subject = rngSubject
.Attachments.Add sFileSaveName1
'.Attachments.Add sFileSaveName2
.HTMLBody = rngBody & .HTMLBody
End With
' copy Name to Clip Board
Dim savedAsNameWithExt
Dim savedAsNameWithOutExt As String
savedAsNameWithExt = Split(sFileSaveName1, "\")
savedAsNameWithOutExt = Left(savedAsNameWithExt(UBound(savedAsNameWithExt)), InStr(savedAsNameWithExt(UBound(savedAsNameWithExt)), ".") - 1)
'MsgBox savedAsNameWithOutExt
Clipboard savedAsNameWithOutExt
End Sub