Email Coding works in one form but not the other...

K

Karissa

I have this code in one form and it works perfectly:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Save Alert - Please Confirm"
.Body = "Agent: " & Forms![frmLogIn]![Combo22] & vbCrLf & vbCrLf & _
"CS#: " & Forms![frmwinbacksave]![cs#] & vbCrLf & vbCrLf & _
"Contract#: " & Forms![frmwinbacksave]![contract#] & vbCrLf & vbCrLf
& _
"Type: " & Forms![frmwinbacksave]![CMFM] & vbCrLf & vbCrLf & _
"Letter Voided: " & Forms![frmwinbacksave]![LetterVoided] & vbCrLf &
vbCrLf & _
"Old Rate: " & Forms![frmwinbacksave]![OldRate] & vbCrLf & vbCrLf & _
"New Rate: " & Forms![frmwinbacksave]![NewRate] & vbCrLf & vbCrLf & _
"Credit Issued: " & Forms![frmwinbacksave]![CreditIssued] & vbCrLf &
vbCrLf & _
"Service Ticket: " & Forms![frmwinbacksave]![ServiceTicket] & vbCrLf
& vbCrLf & _
"Term of Negotiated Offer: " &
Forms![frmwinbacksave]![TermOfNegotOffer] & vbCrLf & vbCrLf & _
"CED Before Save: " & Forms![frmwinbacksave]![CEDbeforeSave] &
vbCrLf & vbCrLf & _
"I took this call myself: " & IIf(Forms![frmwinbacksave]![TookCall]
= -1, "Yes", "No") & vbCrLf & vbCrLf & _
"Verifier: " & Forms![frmwinbacksave]![Verifier]
.Send
End With

Set mailNewMail = Nothing



I have this code in another form and it works:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Survey Alert - Dissatisfied Response"
.Body = "Customer Number: " & Forms![frmsurvey]![CustomerNumber]
.Send
End With

When I try to expand on the coding in the 2nd form using the 1st form as an
example:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Survey Alert - Dissatisfied Response"
.Body = "Customer Number: " & Forms![frmsurvey]![CustomerNumber] &
vbCrLf & vbCrLf & _
"Q1: " = Forms![frmsurvey]![Question1] & vbCrLf & vbCrLf & _
"Q2: " = Forms![frmsurvey]![Question2] & vbCrLf & vbCrLf & _
"Q3: " = Forms![frmsurvey]![Question3] & vbCrLf & vbCrLf & _
"Q4: " = Forms![frmsurvey]![Question4] & vbCrLf & vbCrLf & _
"Q5b: " = Forms![frmsurvey]![Question5b] & vbCrLf & vbCrLf & _
"Q6b: " = Forms![frmsurvey]![Question6b] & vbCrLf & vbCrLf & _
"Q7b: " = Forms![frmsurvey]![Question7b] & vbCrLf & vbCrLf & _
"Q7c: " = Forms![frmsurvey]![Question7c] & vbCrLf & vbCrLf & _
"Q8: " = Forms![frmsurvey]![Question8]
.Send
End With



The body of the email says "False".


I'm at a loss...

Help? Please?
 
D

Dirk Goldgar

Karissa said:
I have this code in one form and it works perfectly:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Save Alert - Please Confirm"
.Body = "Agent: " & Forms![frmLogIn]![Combo22] & vbCrLf & vbCrLf &
_
"CS#: " & Forms![frmwinbacksave]![cs#] & vbCrLf & vbCrLf & _
"Contract#: " & Forms![frmwinbacksave]![contract#] & vbCrLf &
vbCrLf
& _
"Type: " & Forms![frmwinbacksave]![CMFM] & vbCrLf & vbCrLf & _
"Letter Voided: " & Forms![frmwinbacksave]![LetterVoided] & vbCrLf
&
vbCrLf & _
"Old Rate: " & Forms![frmwinbacksave]![OldRate] & vbCrLf & vbCrLf &
_
"New Rate: " & Forms![frmwinbacksave]![NewRate] & vbCrLf & vbCrLf &
_
"Credit Issued: " & Forms![frmwinbacksave]![CreditIssued] & vbCrLf
&
vbCrLf & _
"Service Ticket: " & Forms![frmwinbacksave]![ServiceTicket] &
vbCrLf
& vbCrLf & _
"Term of Negotiated Offer: " &
Forms![frmwinbacksave]![TermOfNegotOffer] & vbCrLf & vbCrLf & _
"CED Before Save: " & Forms![frmwinbacksave]![CEDbeforeSave] &
vbCrLf & vbCrLf & _
"I took this call myself: " &
IIf(Forms![frmwinbacksave]![TookCall]
= -1, "Yes", "No") & vbCrLf & vbCrLf & _
"Verifier: " & Forms![frmwinbacksave]![Verifier]
.Send
End With

Set mailNewMail = Nothing



I have this code in another form and it works:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Survey Alert - Dissatisfied Response"
.Body = "Customer Number: " & Forms![frmsurvey]![CustomerNumber]
.Send
End With

When I try to expand on the coding in the 2nd form using the 1st form as
an
example:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Survey Alert - Dissatisfied Response"
.Body = "Customer Number: " & Forms![frmsurvey]![CustomerNumber] &
vbCrLf & vbCrLf & _
"Q1: " = Forms![frmsurvey]![Question1] & vbCrLf & vbCrLf &
_
"Q2: " = Forms![frmsurvey]![Question2] & vbCrLf & vbCrLf &
_
"Q3: " = Forms![frmsurvey]![Question3] & vbCrLf & vbCrLf &
_
"Q4: " = Forms![frmsurvey]![Question4] & vbCrLf & vbCrLf &
_
"Q5b: " = Forms![frmsurvey]![Question5b] & vbCrLf & vbCrLf
& _
"Q6b: " = Forms![frmsurvey]![Question6b] & vbCrLf & vbCrLf
& _
"Q7b: " = Forms![frmsurvey]![Question7b] & vbCrLf & vbCrLf
& _
"Q7c: " = Forms![frmsurvey]![Question7c] & vbCrLf & vbCrLf
& _
"Q8: " = Forms![frmsurvey]![Question8]
.Send
End With



The body of the email says "False".


I'm at a loss...

Help? Please?


You have some equals signs (=) where you should have ampersands (&) to
concatenate values into your body string. Try this:

.Body = _
"Customer Number: " & Forms![frmsurvey]![CustomerNumber] & _
vbCrLf & vbCrLf & _
"Q1: " & Forms![frmsurvey]![Question1] & vbCrLf & vbCrLf & _
"Q2: " & Forms![frmsurvey]![Question2] & vbCrLf & vbCrLf & _
"Q3: " & Forms![frmsurvey]![Question3] & vbCrLf & vbCrLf & _
"Q4: " & Forms![frmsurvey]![Question4] & vbCrLf & vbCrLf & _
"Q5b: " & Forms![frmsurvey]![Question5b] & vbCrLf & vbCrLf & _
"Q6b: " & Forms![frmsurvey]![Question6b] & vbCrLf & vbCrLf & _
"Q7b: " & Forms![frmsurvey]![Question7b] & vbCrLf & vbCrLf & _
"Q7c: " & Forms![frmsurvey]![Question7c] & vbCrLf & vbCrLf & _
"Q8: " & Forms![frmsurvey]![Question8]
 
K

Karissa

Thank you! I'm not surprised to see it's something like that - it's like a
typo in an English paper, I'll NEVER find it if I wrote it!

Dirk Goldgar said:
Karissa said:
I have this code in one form and it works perfectly:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Save Alert - Please Confirm"
.Body = "Agent: " & Forms![frmLogIn]![Combo22] & vbCrLf & vbCrLf &
_
"CS#: " & Forms![frmwinbacksave]![cs#] & vbCrLf & vbCrLf & _
"Contract#: " & Forms![frmwinbacksave]![contract#] & vbCrLf &
vbCrLf
& _
"Type: " & Forms![frmwinbacksave]![CMFM] & vbCrLf & vbCrLf & _
"Letter Voided: " & Forms![frmwinbacksave]![LetterVoided] & vbCrLf
&
vbCrLf & _
"Old Rate: " & Forms![frmwinbacksave]![OldRate] & vbCrLf & vbCrLf &
_
"New Rate: " & Forms![frmwinbacksave]![NewRate] & vbCrLf & vbCrLf &
_
"Credit Issued: " & Forms![frmwinbacksave]![CreditIssued] & vbCrLf
&
vbCrLf & _
"Service Ticket: " & Forms![frmwinbacksave]![ServiceTicket] &
vbCrLf
& vbCrLf & _
"Term of Negotiated Offer: " &
Forms![frmwinbacksave]![TermOfNegotOffer] & vbCrLf & vbCrLf & _
"CED Before Save: " & Forms![frmwinbacksave]![CEDbeforeSave] &
vbCrLf & vbCrLf & _
"I took this call myself: " &
IIf(Forms![frmwinbacksave]![TookCall]
= -1, "Yes", "No") & vbCrLf & vbCrLf & _
"Verifier: " & Forms![frmwinbacksave]![Verifier]
.Send
End With

Set mailNewMail = Nothing



I have this code in another form and it works:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Survey Alert - Dissatisfied Response"
.Body = "Customer Number: " & Forms![frmsurvey]![CustomerNumber]
.Send
End With

When I try to expand on the coding in the 2nd form using the 1st form as
an
example:

Dim olkApp As New Outlook.Application
Dim mailNewMail As Outlook.MailItem

Set mailNewMail = olkApp.CreateItem(olMailItem)
With mailNewMail
.To = "(e-mail address removed);[email protected]"
.CC = ""
.BCC = ""
.Subject = "Survey Alert - Dissatisfied Response"
.Body = "Customer Number: " & Forms![frmsurvey]![CustomerNumber] &
vbCrLf & vbCrLf & _
"Q1: " = Forms![frmsurvey]![Question1] & vbCrLf & vbCrLf &
_
"Q2: " = Forms![frmsurvey]![Question2] & vbCrLf & vbCrLf &
_
"Q3: " = Forms![frmsurvey]![Question3] & vbCrLf & vbCrLf &
_
"Q4: " = Forms![frmsurvey]![Question4] & vbCrLf & vbCrLf &
_
"Q5b: " = Forms![frmsurvey]![Question5b] & vbCrLf & vbCrLf
& _
"Q6b: " = Forms![frmsurvey]![Question6b] & vbCrLf & vbCrLf
& _
"Q7b: " = Forms![frmsurvey]![Question7b] & vbCrLf & vbCrLf
& _
"Q7c: " = Forms![frmsurvey]![Question7c] & vbCrLf & vbCrLf
& _
"Q8: " = Forms![frmsurvey]![Question8]
.Send
End With



The body of the email says "False".


I'm at a loss...

Help? Please?


You have some equals signs (=) where you should have ampersands (&) to
concatenate values into your body string. Try this:

.Body = _
"Customer Number: " & Forms![frmsurvey]![CustomerNumber] & _
vbCrLf & vbCrLf & _
"Q1: " & Forms![frmsurvey]![Question1] & vbCrLf & vbCrLf & _
"Q2: " & Forms![frmsurvey]![Question2] & vbCrLf & vbCrLf & _
"Q3: " & Forms![frmsurvey]![Question3] & vbCrLf & vbCrLf & _
"Q4: " & Forms![frmsurvey]![Question4] & vbCrLf & vbCrLf & _
"Q5b: " & Forms![frmsurvey]![Question5b] & vbCrLf & vbCrLf & _
"Q6b: " & Forms![frmsurvey]![Question6b] & vbCrLf & vbCrLf & _
"Q7b: " & Forms![frmsurvey]![Question7b] & vbCrLf & vbCrLf & _
"Q7c: " & Forms![frmsurvey]![Question7c] & vbCrLf & vbCrLf & _
"Q8: " & Forms![frmsurvey]![Question8]

--
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top