Results 1 to 6 of 6
  1. #1
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862

    I lose text output in email when I link my Signaure Block

    If I run the code as such and it works:

    Code:
     
     Dim rs As Dao.Recordset   
     Dim objOutlook As Outlook.application
     Dim objOutlookMsg, objOutlookMsg1, objOutlookMsg2 As Outlook.MailItem
     Dim objOutlookAttach As Outlook.Attachment
     Dim strMsg As String
     Dim CRNum, DateTypes As Variant
      Set rs = CurrentDb.OpenRecordset("SELECT Status,CR_Numbers,[Change Requested]FROM Daily_Actions_Email ORDER BY Status,CR_ID ASC")
      Set objOutlook = CreateObject("Outlook.Application")
      Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
      Set objOutlookMsg1 = objOutlook.CreateItem(olMailItem)
      Set objOutlookMsg2 = objOutlook.CreateItem(olMailItem)
    CRNum = DLookup("[CR_Numbers]", "[Daily_Actions_Email]")
    If IsNull(CRNum) Then
    With objOutlookMsg
        .Subject = "There were no actioned CR's - " & Tod
        .Body = "The email addressing is a living entity.  If there are corrections, additions, or deletions, please notify the sender." & vbCrLf & vbCrLf & _
                "There were no actioned Change Requests for " & Tod & "." & strSigBlock
        .To = "CCB Results"
        .Display
        DoCmd.Close acReport, "Daily Actions"
    Exit Sub
    End With
    Else
    End If
    rs.MoveFirst
    While Not rs.EOF
     strMsg = strMsg & rs!Status & vbCrLf & Chr(9) & "CR  " & rs!CR_Numbers & " - " & rs![Change Requested] & vbCrLf
     rs.MoveNext
    Wend
     rs.Close
    With objOutlookMsg1
       .Subject = "Today's AORB/ERB/CCB outcome - " & Tod
        .Body = "The email addressing is a living entity.  If there are corrections, additions, or deletions, please notify the sender." & vbCrLf & vbCrLf & _
       "Today's AORB/ERB/CCB outcome." & vbCrLf & vbCrLf & vbCrLf & vbCrLf & "V/R" & vbCrLf & vbCrLf & "Name" & vbCrLf & vbCrLf & "Command" & vbCrLf & "Division" & vbCrLf & "Address1" & vbCrLf & "City and Zip" & vbCrLf & "Phone" & vbCrLf & "EMail"
        DoCmd.OutputTo 3, "Daily Actions", acFormatPDF, "C:\Temp\Daily Actions - " & Tod & ".pdf", , 0
        .Attachments.Add ("C:\Temp\Daily Actions - " & Tod & ".pdf")
        .To = "CCB Results"
        .Display
        DoCmd.Close acReport, "Daily Actions"
        Kill "C:\Temp\Daily Actions - " & Format(Date, "dd mmm yyyy") & ".pdf"
     End With
    strMsg = ""
    If IsNull([CRNum]) Then
    End If
    With objOutlookMsg2.........
    I made changes as shown in Orange Bold letters


    Output looks like:

    The email addressing is a living entity. If there are corrections, additions, or deletions, please notify the sender.



    Today's AORB/ERB/CCB outcome.

    Status
    CR ### What was requested
    Status
    CR ### What was requested
    Status
    CR ### What was requested

    Signature block


    If I change it to:
    Code:
    With objOutlookMsg1
       .Subject = "Today's AORB/ERB/CCB outcome - " & Tod
         .Body = "The email addressing is a living entity.  If there are  corrections, additions, or deletions, please notify the sender." &  vbCrLf & vbCrLf & _
       "Today's AORB/ERB/CCB outcome." & strSigBlock
    I lose my text output on the email.

    Output looks like:

    The email addressing is a living entity. If there are corrections, additions, or deletions, please notify the sender.

    Today's AORB/ERB/CCB outcome.


    Signature block


    What am I missing here?

    Sig Block code =
    Code:
    Option Compare Database
    Public Const strSigBlock As String = vbCrLf & vbCrLf & "For your action." &"V/R" & vbCrLf & vbCrLf  & "Name" & vbCrLf & vbCrLf & "Command" & vbCrLf  & "Division" & vbCrLf & "Address1" & vbCrLf & "City  and Zip" & vbCrLf & "Phone" & vbCrLf & "EMail"

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,369
    A few irregularities that might contribute to the issue.
    - do you realize that all of these declarations are variants: objOutlookMsg, objOutlookMsg1, CRNum, because you have not properly declared them.
    objOutlookMsg As Outlook.MailItem, objOutlookMsg1 As Outlook.MailItem (etc). Where not explicitly declared, they are variants.
    - Also, I don't believe you can pass vbCrLf to html mail and get a paragraph/line feed as html does not recognize the vb equivalent. You need the "<P>" equivalent. It might be even more problematic to start a string with two of the vb references as you are doing.
    - suggest you put a debug.print line or check the constructs you think you are concatenating in the immediate window. You will probably find it looks OK in Access, but again, it's been my experience that you can't use vbCrLf in html emails.
    edit: suggest you dump the debug output into Notepad, save as Note.htm and open that file. The default handler should be your browser, and you can see how the email body will be interpreted by Outlook (save possibly the formatting may have to be tweaked later).
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    Micron,
    How do I properly declare? As for the Email type. I we do not use HTML email as a standard.

    I don't get an error, so access is not seeing a fault.

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,369
    Quote Originally Posted by Thompyt View Post
    Micron,
    How do I properly declare?
    The answer to that was given:
    Dim objOutlookMsg As Outlook.MailItem, objOutlookMsg1 As Outlook.MailItem

    Dim intCount as Integer, intFirst as Integer, intLast as Integer not
    Dim intCount, intFirst, intLast as Integer
    As for the Email type. I we do not use HTML email as a standard.
    Are you saying vbcrlf in plain text email works in Outlook?

    I don't get an error, so access is not seeing a fault.
    That is a matter of luck that the variant data type can be used by your process. It is often the case, but once in a while it will fail. The important thing is that you realize your syntax makes the undeclared variables become variants.

  5. #5
    Thompyt is offline Expert
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2014
    Location
    El Paso, TX
    Posts
    862
    Thanks for the clarification. I gather I have too little of variants and strings to make a difference as I never got any faults the way I was doign it. I changed it to what was provided, so that I could get into the correct pattern on later projects. vbCrlf works for me fine, I didn't know there was any other way to do it. Except Chr(10) Chr(13). I figured out what happened. I dropped the strmsg from the middle of the .body statement. once I added it back in, it was good to go.

  6. #6
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,369
    Glad you got it solved. Probably most of the time, you would not notice, but certain operations on numeric data that has been assigned to a variant can cause issues, as well as trying to assign a fixed length string to a variant (not allowed). What's important is that you now know that by not declaring a variable explicitly, it is a variant.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 09-15-2015, 05:37 AM
  2. Replies: 5
    Last Post: 07-21-2015, 05:27 AM
  3. Replies: 2
    Last Post: 03-31-2015, 08:54 AM
  4. Verifing Data in a text box when it lose focus...
    By hswilliams2525 in forum Access
    Replies: 1
    Last Post: 01-17-2012, 08:36 PM
  5. Email Link
    By rovman in forum Programming
    Replies: 2
    Last Post: 12-11-2011, 09:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums