DanOfEarth
06-17-2010, 10:26 AM
This sub routine creates an email, adds attachents, uses a MS Word doc for the body, then sends the email off.
I was adding things to my sub here, and suddenly when I hit the button to run this, it no longer "sends" the email. It just saves a draft of it in Outlook. Very weird.
Sub SendDocAsMsg2()
Dim wd As Object
Dim doc As Object
Dim itm As Object
Dim ID As String
Dim blnWeOpenedWord As Boolean
On Error Resume Next
Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
blnWeOpenedWord = True
End If
Set doc = wd.Documents.Open _
(Filename:="C:\Documents and Settings\Dan\Desktop\SHORT SELL\Email3.docx", ReadOnly:=True)
Set itm = doc.MailEnvelope.Item
With itm
.To = ActiveCell.Text
.Subject = "Important: A bulk of the Contracts to sign. Please forward to seller"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9a - Authorization 1st Mortgage - MK - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9b - Authorization 1st Mortgage - ZS - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "13 - HAFA Letter - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "12 - Notice of Contract - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "17 - Agreement of Negotiator - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "10a - Termination of Authorization - 1st - " & Range("Address") & ".pdf"
If Dir(Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9c - Authorization 2nd Mortgage - MK - " & Range("Address") & ".pdf") <> "" Then
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9c - Authorization 2nd Mortgage - MK - " & Range("Address") & ".pdf"
Else
End If
If Dir(Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9d - Authorization 2nd Mortgage - ZS - " & Range("Address") & ".pdf") <> "" Then
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9d - Authorization 2nd Mortgage - ZS - " & Range("Address") & ".pdf"
Else
End If
If Dir(Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "10b - Termination of Authorization - 2nd - " & Range("Address") & ".pdf") <> "" Then
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "10b - Authorization 2nd Mortgage - 2nd - " & Range("Address") & ".pdf"
Else
End If
.Save
ID = .EntryID
Set itm = Application.Session.GetItemFromID(ID)
itm.Send
doc.Close wdDoNotSaveChanges
End With
If blnWeOpenedWord Then
wd.Quit
End If
Set doc = Nothing
Set itm = Nothing
Set wd = Nothing
End Sub
As noted in the red script, I've got the .Send in there. Any thoughts?
I was adding things to my sub here, and suddenly when I hit the button to run this, it no longer "sends" the email. It just saves a draft of it in Outlook. Very weird.
Sub SendDocAsMsg2()
Dim wd As Object
Dim doc As Object
Dim itm As Object
Dim ID As String
Dim blnWeOpenedWord As Boolean
On Error Resume Next
Set wd = GetObject(, "Word.Application")
If wd Is Nothing Then
Set wd = CreateObject("Word.Application")
blnWeOpenedWord = True
End If
Set doc = wd.Documents.Open _
(Filename:="C:\Documents and Settings\Dan\Desktop\SHORT SELL\Email3.docx", ReadOnly:=True)
Set itm = doc.MailEnvelope.Item
With itm
.To = ActiveCell.Text
.Subject = "Important: A bulk of the Contracts to sign. Please forward to seller"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9a - Authorization 1st Mortgage - MK - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9b - Authorization 1st Mortgage - ZS - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "13 - HAFA Letter - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "12 - Notice of Contract - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "17 - Agreement of Negotiator - " & Range("Address") & ".pdf"
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "10a - Termination of Authorization - 1st - " & Range("Address") & ".pdf"
If Dir(Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9c - Authorization 2nd Mortgage - MK - " & Range("Address") & ".pdf") <> "" Then
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9c - Authorization 2nd Mortgage - MK - " & Range("Address") & ".pdf"
Else
End If
If Dir(Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9d - Authorization 2nd Mortgage - ZS - " & Range("Address") & ".pdf") <> "" Then
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "9d - Authorization 2nd Mortgage - ZS - " & Range("Address") & ".pdf"
Else
End If
If Dir(Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "10b - Termination of Authorization - 2nd - " & Range("Address") & ".pdf") <> "" Then
.Attachments.Add Range("DIRECTORY") & Range("Agent") & " - " & Range("Address") & "\Orig Docs\" & "10b - Authorization 2nd Mortgage - 2nd - " & Range("Address") & ".pdf"
Else
End If
.Save
ID = .EntryID
Set itm = Application.Session.GetItemFromID(ID)
itm.Send
doc.Close wdDoNotSaveChanges
End With
If blnWeOpenedWord Then
wd.Quit
End If
Set doc = Nothing
Set itm = Nothing
Set wd = Nothing
End Sub
As noted in the red script, I've got the .Send in there. Any thoughts?