Hi,
I created VBA code to send email from a form. This code opens outlook that let us edit the form before out.
Question -- I want to use 2 different forms to send out email in the Body section. The 2 forms are almost same but sometimes I want to add one sentence for greeting but sometimes it doesn't need.
How and where do I change the code ?
Here are my code that I'm using.
Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
objEmail.Display
strBody = strBody & "Dear " & dName & "," & Chr(13) & Chr(13)
strBody = strBody & "Inquiry No.: " & "Q" & " " & QNo & Chr(13) & Chr(13)
strBody = strBody & " Form Factor: " & ProducType & Chr(13)
strBody = strBody & " Input: " & inpuType & Chr(13)
strBody = strBody & " Output: " & Output & Chr(13)
strBody = strBody & " Dimensions: " & Dimension & Chr(13)
..............
..............
With objEmail
.Subject = "Q " & QNo & " " & Title
.Body = strBody
End With
Set objEmail = Nothing
Exit_cmdSendEmail_Click:
Exit Sub
Err_cmdSendEmail_Click:
MsgBox Err.Description
Resume Exit_cmdSendEmail_Click
End Sub
I created VBA code to send email from a form. This code opens outlook that let us edit the form before out.
Question -- I want to use 2 different forms to send out email in the Body section. The 2 forms are almost same but sometimes I want to add one sentence for greeting but sometimes it doesn't need.
How and where do I change the code ?
Here are my code that I'm using.
Private Sub cmdSendEmail_Click()
On Error GoTo Err_cmdSendEmail_Click
Dim strEmail, strBody As String
Dim objOutlook As Outlook.Application
Dim objFolder As Outlook.MAPIFolder
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
objEmail.Display
strBody = strBody & "Dear " & dName & "," & Chr(13) & Chr(13)
strBody = strBody & "Inquiry No.: " & "Q" & " " & QNo & Chr(13) & Chr(13)
strBody = strBody & " Form Factor: " & ProducType & Chr(13)
strBody = strBody & " Input: " & inpuType & Chr(13)
strBody = strBody & " Output: " & Output & Chr(13)
strBody = strBody & " Dimensions: " & Dimension & Chr(13)
..............
..............
With objEmail
.Subject = "Q " & QNo & " " & Title
.Body = strBody
End With
Set objEmail = Nothing
Exit_cmdSendEmail_Click:
Exit Sub
Err_cmdSendEmail_Click:
MsgBox Err.Description
Resume Exit_cmdSendEmail_Click
End Sub