Anne Troy
MrExcel MVP
- Joined
- Feb 18, 2002
- Messages
- 2,632
- Office Version
- 365
- Platform
- Windows
Why would this code work perfectly in one workbook and not at all in another? I changed the ranges to add to the body to be named ranges, but even after reverting back to cell references, I get NO message body. The funny thing is that on the code below, I could not seem to get it to add an Outlook signature. However, when I run the code in workbook 2, it creates NO message body but DOES add my Outlook signature.
Bizarro. Any ideas? Thanks!
Bizarro. Any ideas? Thanks!
Code:
Sub SendMeOut()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim strbody As String
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = Range("'Dashboard'!D3").Text
.CC = Range("'Dashboard'!D4").Text & ";" & Range("'Dashboard'!D5").Text & Range("progemail").Text
.BCC = Range("'Dashboard'!D6").Text
.Subject = "Harbortouch POS Order Update: " & Range("merchantname").Text & " " & Range("merchantmid").Text
.Body = Range("'Email Text'!$C$16").Text & Chr(10) & Chr(10) & _
Range("'Email Text'!$C$18").Text & Chr(10) & Chr(10) & _
Range("'Email Text'!$C$20").Text & Chr(10) & Chr(10) & _
Range("'Email Text'!$C$21").Text & Chr(10) & Chr(10) & _
Range("'Email Text'!$C$22").Text & Chr(10) & Chr(10) & _
Range("'Email Text'!$C$23").Text & Chr(10) & Chr(10)
.Display 'Or use Send
End With
On Error GoTo 0
Set OutMail = Nothing
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub