Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code for Email issues

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
Below is the code that I have for sending an email from a
form. The part that is in bold below is for the CC portion
of the email. What is not working is the:
Me.RequestedBy.Value@nmhg.com portion.
This shows up in the email exactly as above. I want it to show as
whatever the value is in the Me.RequestedBy field with
@nmhg. If the Value in Me.RequestedBy field is Kevin
Thompson then it should show in the email as:
Kevin Thompson@nmhg.com

I am doing something wrong but cannot figure it out. Please
help!!!

Code:
Sub SendMail9()

'Approved by to Finance

       DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

       Dim clsSendObject As accSendObject
       Dim strMsg As String
       Dim emailsubject As String
       Dim emailtext As String
       Dim SL As String, DL As String
       Dim toEmail As String
      
       SL = vbNewLine
       DL = SL & SL

       emailsubject = "Form #" & Me.FormId.Value & "; Finance, Please Approve or Disapprove this Form."

       emailtext = "Form #" & Me.FormId.Value & DL & _
       "1. Please go to appropriate Form (FormPurchasedToMakeFrm) and then to the Form Number Listed above" & SL & _
       "2. Complete your Checklist" & SL & _
       "3. Next, Click Finance1 CheckBox in Routing above to Forward Form to BOM Analyst" & DL & _
       "Thank you for your help" & DL & _
       DLookup("ActualName", "ChangeFormUserNameTbl", "LoginName='" & GetCurrentUserName() & "'") & SL & _
       "Engineering Manager"
 
       toEmail = "abscombs@nmhg.com"

       Set clsSendObject = New accSendObject
       strMsg = String(3000, "a")
       clsSendObject.SendObject , , accOutputrtf, _
       toEmail, [b]DLookup("LoginName", "ChangeFormUserNameTbl", "ActualName='" & Me.EcnBomAnalystAssigned & "'") & _
       "@nmhg.com; Me.RequestedBy.Value@nmhg.com"[/b], , emailsubject, emailtext, True
       Set clsSendObject = Nothing
 
End Sub
 
I found out that I have to do another DLookup which I did and it works when it is in the BCC part of the code.
I now need to figure out how to get it into the CC part of the code along with the other DLookup that is
already there. Any Advice??
Code:
Sub SendMail9()'Approved by to Finance       DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70       Dim clsSendObject As accSendObject       Dim strMsg As String       Dim emailsubject As String       Dim emailtext As String       Dim SL As String, DL As String       Dim toEmail As String             SL = vbNewLine       DL = SL & SL       emailsubject = "Form #" & Me.FormId.Value & "; Finance, Please Approve or Disapprove this Form."       emailtext = "Form #" & Me.FormId.Value & DL & _       "1. Please go to appropriate Form (FormPurchasedToMakeFrm) and then to the Form Number Listed above" & SL & _       "2. Complete your Checklist" & SL & _       "3. Next, Click Finance1 CheckBox in Routing above to Forward Form to BOM Analyst" & DL & _       "Thank you for your help" & DL & _       DLookup("ActualName", "ChangeFormUserNameTbl", "LoginName='" & GetCurrentUserName() & "'") & SL & _       "Engineering Manager"        toEmail = "abscombs@nmhg.com"       Set clsSendObject = New accSendObject       strMsg = String(3000, "a")       clsSendObject.SendObject , , accOutputrtf, _       toEmail, DLookup("LoginName", "ChangeFormUserNameTbl", "ActualName='" & Me.EcnBomAnalystAssigned & "'") & _       "@nmhg.com", [b]DLookup("LoginName", "ChangeFormUserNameTbl", "ActualName='" & Me.RequestedBy & "'") & _       "@nmhg.com"[/b], emailsubject, emailtext, True       Set clsSendObject = Nothing End Sub
 
I guess my real question is how can I make the code look up two fields?
 
FYI,

I received some suggestions from another forum and below
is the correct code.

Code:
Sub SendMail9()

'Approved by to Finance

       DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

       Dim clsSendObject As accSendObject
       Dim strMsg As String
       Dim emailsubject As String
       Dim emailtext As String
       Dim SL As String, DL As String
       Dim toEmail As String
       Dim ccEmail1 As String
       Dim ccEmail2 As String
             
       SL = vbNewLine
       DL = SL & SL

       emailsubject = "Form #" & Me.FormId.Value & "; Finance, Please Approve or Disapprove this Form."

       emailtext = "Form #" & Me.FormId.Value & DL & _
       "1. Please go to appropriate Form (FormPurchasedToMakeFrm) and then to the Form Number Listed above" & SL & _
       "2. Complete your Checklist" & SL & _
       "3. Next, Click Finance1 CheckBox in Routing above to Forward Form to BOM Analyst" & DL & _
       "Thank you for your help" & DL & _
       DLookup("ActualName", "ChangeFormUserNameTbl", "LoginName='" & GetCurrentUserName() & "'") & SL & _
       "Engineering Manager"
 
       toEmail = "abscombs@nmhg.com"
       ccEmail1 = DLookup("LoginName", "ChangeFormUserNameTbl", "ActualName='" & Me.RequestedBy & "'") & "@nmhg.com"
       ccEmail2 = DLookup("LoginName", "ChangeFormUserNameTbl", "ActualName='" & Me.EcnBomAnalystAssigned & "'") & "@nmhg.com"

       Set clsSendObject = New accSendObject
       strMsg = String(3000, "a")
       clsSendObject.SendObject , , accOutputrtf, _
       toEmail, ccEmail1 & ";" & ccEmail2, , emailsubject, emailtext, True
       Set clsSendObject = Nothing
 
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top