email field

kitty77

Registered User.
Local time
Today, 07:16
Joined
May 27, 2019
Messages
715
I'm using the following code...

DoCmd.SendObject acSendReport, "BRODS", acFormatPDF, 'to@email.com', "cc@email.com", "bcc@email.com", "Subject", "Body Text", True

It works fine but how can I make the to@email.com be a field value from my form. Say [custemail]

Thanks...
 
Use

Me.custemail

For that argument.
 
Where do I put that? Can you show me an example?
 
In other words, where you had "to@email.com", replace it with Me.custemail.
 
I thought I tried that... Damn, now it works perfect. Thanks!
 
Geez, I guess I was too slow. :rolleyes:
 
How can I make this come over as HTML email? Now, it comes over as text email?

Thanks...
 
you need Outlook automation:
Code:
Option Compare Database
Option Explicit

' need to Reference Microsoft Outlook XX.X Object Library in VBE->Tools->Reference
' arnelgp
'
Public Function CreateEmailWithOutlook( _
    MessageTo As String, _
    MessageCC As String, _
    Subject As String, _
    MessageBody As String, _
    AttachmentFile As Variant)

    ' Define app variable and get Outlook using the "New" keyword
    ' comment out if using late binding
    Dim olApp As New Outlook.Application
    Dim olMailItm As Outlook.MailItem  ' An Outlook Mail item
    Dim olFolder As Outlook.folder
    Dim olNameSpace As Outlook.NameSpace
 
    '* uncomment if using late binding
    '*Dim olApp As Object
    '*Dim olMailItm As Object
    '*Dim olFolder As Object
    '*Dim olNameSpace As Object
    
    
    Dim varItem As Variant

    Set olApp = New Outlook.Application
    '* uncomment if using late binding
    '*Set olApp = CreateObject("Outlook.Application")
    
    Set olNameSpace = olApp.GetNamespace("MAPI")
    Set olFolder = olNameSpace.GetDefaultFolder(olFolderInbox)
    ' Create a new email object
    Set olMailItm = olFolder.Items.Add(olMailItem)

    ' Add the To/Subject/Body to the message and display the message
    With olMailItm
        .To = MessageTo
        '.CC = MessageCC
        '.Subject = Subject
        .HTMLBody = MessageBody
        '.Body = MessageBody
        ' request a readers reciept so I know the email has been read
        .ReadReceiptRequested = True
        If IsArray(AttachmentFile) Then
            For Each varItem In AttachmentFile
                .Attachments.Add varItem
            Next
        Else
            If Trim(AttachmentFile & "") <> "" Then _
                .Attachments.Add AttachmentFile
        End If
        .Display    ' To show the email message to the user
        '.Send      ' uncomment to send directly
    End With

    ' Release all object variables
    Set olMailItm = Nothing
    Set olFolder = Nothing
    Set olNameSpace = Nothing
    Set olApp = Nothing

End Function
 
How can I make this come over as HTML email? Now, it comes over as text email?

Thanks...
Hi. Arnel is correct but what are you wanting to convert to HTML? You are sending a PDF attachment, that should come through as a PDF attachment. Are you composing a huge HTML email body that we can't see here?
 
Basically to add a signature. The basic text is fine but I have to manually convert it to HTML to add the signature. I've tried a bunch of examples so far and no luck. Do you know of an simple examples?
 
Basically to add a signature. The basic text is fine but I have to manually convert it to HTML to add the signature. I've tried a bunch of examples so far and no luck. Do you know of an simple examples?
Are you referring to the signature from Outlook? If not, what is special about this signature, does it have colored and styled fonts and an image or something? Just curious... If the body of the email has to be HTML, then you could try writing HTML tags in it. For example, what do you get if you do this simple email?
Code:
DoCmd.SendObject acSendNoObject, , , "to@email.com", , , "Test Subject", "<b>Hello World!</b><br><p>This is the first paragraph.</p><p>This is the second paragraph.</p><i>Sincerely,</i>", True
 
Yes, a graphic. But I think what you just provided will work just fine. Thanks!
 
So, here is what I'm using... Works well but I'm getting an annoying extra blank line in the body of the email. Before the Hello. Can't figure out why?

DoCmd.SendObject _
acSendReport, _
"BASS", _
acFormatPDF, _
[Memailsent], _
, _
, _
"Testing 123", _
"Hello" & Chr(10) & _
"Another line of text" & Chr(10) & Chr(10) & _
"Thank You," & Chr(10) & _
"Steve", _
True
 
So, here is what I'm using... Works well but I'm getting an annoying extra blank line in the body of the email. Before the Hello. Can't figure out why?

DoCmd.SendObject _
acSendReport, _
"BASS", _
acFormatPDF, _
[Memailsent], _
, _
, _
"Testing 123", _
"Hello" & Chr(10) & _
"Another line of text" & Chr(10) & Chr(10) & _
"Thank You," & Chr(10) & _
"Steve", _
True

Hi. Were you not getting an extra blank line before? Did you get an extra blank line when you tried the one I posted earlier?
 
I not sure... I was using something else and pretty sure I did not get the extra line.
 
I not sure... I was using something else and pretty sure I did not get the extra line.

Hi. Unfortunately, I am currently not in a position to do any testing for you (only using phone), so we'll have to rely on you to tell us what's happening when you try out the suggestions we gave you.
 
Ok, when I send the email without

acSendReport, _
"BASS", _
acFormatPDF, _

It does not put the extra line.
 
Ok, when I send the email without

acSendReport, _
"BASS", _
acFormatPDF, _

It does not put the extra line.

I can't verify it right now, but it must be a bug in the method.
 

Users who are viewing this thread

Back
Top Bottom