473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

VBA: Duplicated code in another form is not working

Hello all, I have this interesting problem and it has me scratching my head. I have updated a few forms to use CDOSYS to email instead of using the doCmd.SendObject.
Expand|Select|Wrap|Line Numbers
  1.         Dim objMessage As Object
  2.         Dim strFromEmail As String
  3.         Dim intCaller As Integer
  4.         Dim strCallerComments As String
  5.         Dim strCallerEmail As String
  6.         Dim strCallerPhoneNumber As String
  7.         Dim strHTMLBody As String
  8.         Dim strDateOfCall As String
  9.         Dim strCallerName As String
  10.         Dim strAssignedTo As String
  11.  
  12.         strFromEmail = DLookup("[E-Mail Address]", "[CSD Personnel]", "[CSD Name] = '" & txtCallLogBy.Value & "'")
  13.         strAssignedTo = DLookup("[CSD Name]", "[CSD Personnel]", "[Initials] = '" & Initials.Value & "'")
  14.         intCaller = UserID.Value
  15.         strCallerName = DLookup("[UserName]", "[Users2]", "[UserID] = " & intCaller)
  16.         strCallerComments = CallerComments.Value
  17.         strCallerEmail = DLookup("[E-MailAddress]", "[Users2]", "[UserName] = '" & strCallerName & "'")
  18.         strCallerPhoneNumber = DLookup("[PhoneNumber]", "[Users2]", "[UserName] = '" & strCallerName & "'")
  19.         strDateOfCall = CallDateTime.Value
  20.  
  21.         strHTMLBody = "<h1>Call Log Email</h1><br><br>" & stSubject & "<br><br>"
  22.         strHTMLBody = strHTMLBody & "<b>Assigned To:</b> " & strAssignedTo & "<br><br>"
  23.         strHTMLBody = strHTMLBody & "<br><br><b>Caller's Name:</b> " & strCallerName & "<br><br>"
  24.         strHTMLBody = strHTMLBody & "<b>Caller's Email:</b> " & strCallerEmail & "<br><br>"
  25.         strHTMLBody = strHTMLBody & "<b>Caller's Phone Number:</b> " & Format(strCallerPhoneNumber, "(###) ###-####") & "<br><br>"
  26.         strHTMLBody = strHTMLBody & "<b>Reason For Calling:</b> " & strCallerComments & "<br><br>"
  27.         strHTMLBody = strHTMLBody & "<b>Date Of Call:</b> " & strDateOfCall
  28.  
  29.         Set objMessage = CreateObject("CDO.Message")
  30.             objMessage.Subject = stSubject
  31.             objMessage.From = strFromEmail
  32.             objMessage.To = stSendTo
  33.             objMessage.HTMLBody = strHTMLBody
  34.             objMessage.Configuration.Fields.Item _
  35.             ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
  36.  
  37.             'Name or IP of Remote SMTP Server
  38.             objMessage.Configuration.Fields.Item _
  39.             ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.truecos.com"
  40.  
  41.             'Server port (typically 25)
  42.             objMessage.Configuration.Fields.Item _
  43.             ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
  44.             objMessage.Configuration.Fields.Update
  45.             objMessage.sEnd
  46.  
This is the code that in 3 of 4 forms is working correctly. On the form that isn't sending, I have stepped through the entire procedure, and set a watch on objMessage. Once I pass send, the object correctly has a sent date, but no email comes!

I am using Access 2003, XP Pro.
Does anyone have any thoughts or ideas?
Thanks,
squiggly12
Mar 14 '08 #1
2 1350
FishVal
2,653 Expert 2GB
Hi, there.

From the code you've posted it is not obvious whether objMessage.To property is being set correctly. Anyway, if the code doesn't raise an error, then, I guess, it means that email was sent but wasn't delivered by mail server.

Regards,
Fish.
Mar 17 '08 #2
Hi, there.

From the code you've posted it is not obvious whether objMessage.To property is being set correctly. Anyway, if the code doesn't raise an error, then, I guess, it means that email was sent but wasn't delivered by mail server.

Regards,
Fish.
Fish,
Thank you for the reply. I have checked all of the variables and they are being set correctly, and the sent date within the objMessage object is happening. I will have our network admin check the mail server to see if there are mails being stopped. The thing that is bothering me is that on 3 other forms, the same exact code is being used and emails are generated and sent.

Thanks again!
Mar 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: bebelino | last post by:
Hello, I've asked this same question two weeks ago or so. So, this is my last shot in hoping there's one person with an answer. I use a lot of SQL statements in my VBA-code. I do it like this:...
6
by: Clément Collin | last post by:
I working on a GIS project, with Access link which just need a little routine in VBA, but I haven't knowledges in VBA language. It's very simple, and it looks like that in a TPascal way : .......
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
6
by: Terry Bell | last post by:
We've had a very large A97 app running fine for the last seven years. I've just converted to SQL Server backend, which is being tested, but meanwhile the JET based version, running under terminal...
15
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to...
6
by: Niyazi | last post by:
Hi all, What is fastest way removing duplicated value from string array using vb.net? Here is what currently I am doing but the the array contains over 16000 items. And it just do it in 10 or...
12
by: Striker | last post by:
I have never used VB, so sorry for the novice questions. I have a very small app in vba that only uses excel as a place to put a button and some code that I need to move to VB. Now it seems...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
3
by: olle | last post by:
How to deal with a VBA-project that is damaged? Hi everyone. I am BigOlle from sweden and I have been working with Accees for ten years I am now working on a project that started in Access97...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.