I am producing an e-mail message to produce the contents of the current record from a form. When the Home, Work or Cell phone isn't present, the e-mail form doesn't work.
Any suggestions?
Code follows:
Private Sub M1_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
strEmail = "acme@test.com"
strBody = strBody & "SM Name: " & Last_Name & " " & First_Name & " " & sMidInit & " " & sRank & Chr(13)
strBody = strBody & Left$(Social, 3) & "-" & Mid$(Social, 4) & " " & SMUnit & Chr(13) & Chr(13)
strBody = strBody & "Home Address" & Chr(13)
strBody = strBody & Address & Chr(13) & City & ", " & State & " " & Zip_Code & Chr(13)
strBody = strBody & "(H) " & Left$(Home_Phone, 3) & "-" & Mid$(Home_Phone, 4, 3) & "-" & Right$(Home_Phone, 4) & Chr(13)
strBody = strBody & "(W) " & Left$(Work_Phone, 3) & "-" & Mid$(Work_Phone, 4, 3) & "-" & Right$(Work_Phone, 4) & Chr(13)
strBody = strBody & "(C) " & Left$(Cell_Phone, 3) & "-" & Mid$(Cell_Phone, 4, 3) & "-" & Right$(Cell_Phone, 4) & Chr(13) & Chr(13)
strBody = strBody & "Work Address" & Chr(13)
strBody = strBody & WAddress & Chr(13) & WCity & ", " & WState & " " & WZip & Chr(13) & Chr(13)
strBody = strBody & AKO_eMail & Chr(13)
With objEmail
.To = strEmail
.Subject = "Soldier Data"
.Body = strBody
.Send
End With
Exit Sub
End Sub
Any suggestions?
Code follows:
Private Sub M1_Click()
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
strEmail = "acme@test.com"
strBody = strBody & "SM Name: " & Last_Name & " " & First_Name & " " & sMidInit & " " & sRank & Chr(13)
strBody = strBody & Left$(Social, 3) & "-" & Mid$(Social, 4) & " " & SMUnit & Chr(13) & Chr(13)
strBody = strBody & "Home Address" & Chr(13)
strBody = strBody & Address & Chr(13) & City & ", " & State & " " & Zip_Code & Chr(13)
strBody = strBody & "(H) " & Left$(Home_Phone, 3) & "-" & Mid$(Home_Phone, 4, 3) & "-" & Right$(Home_Phone, 4) & Chr(13)
strBody = strBody & "(W) " & Left$(Work_Phone, 3) & "-" & Mid$(Work_Phone, 4, 3) & "-" & Right$(Work_Phone, 4) & Chr(13)
strBody = strBody & "(C) " & Left$(Cell_Phone, 3) & "-" & Mid$(Cell_Phone, 4, 3) & "-" & Right$(Cell_Phone, 4) & Chr(13) & Chr(13)
strBody = strBody & "Work Address" & Chr(13)
strBody = strBody & WAddress & Chr(13) & WCity & ", " & WState & " " & WZip & Chr(13) & Chr(13)
strBody = strBody & AKO_eMail & Chr(13)
With objEmail
.To = strEmail
.Subject = "Soldier Data"
.Body = strBody
.Send
End With
Exit Sub
End Sub