email field (1 Viewer)

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:16
Joined
Aug 30, 2003
Messages
36,118
Use

Me.custemail

For that argument.
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
Where do I put that? Can you show me an example?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:16
Joined
Oct 29, 2018
Messages
21,357
In other words, where you had "to@email.com", replace it with Me.custemail.
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
I thought I tried that... Damn, now it works perfect. Thanks!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:16
Joined
Aug 30, 2003
Messages
36,118
Geez, I guess I was too slow. :rolleyes:
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
How can I make this come over as HTML email? Now, it comes over as text email?

Thanks...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:16
Joined
May 7, 2009
Messages
19,169
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:16
Joined
Oct 29, 2018
Messages
21,357
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?
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
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?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:16
Joined
Oct 29, 2018
Messages
21,357
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
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
Yes, a graphic. But I think what you just provided will work just fine. Thanks!
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:16
Joined
Oct 29, 2018
Messages
21,357
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?
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
I not sure... I was using something else and pretty sure I did not get the extra line.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:16
Joined
Oct 29, 2018
Messages
21,357
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.
 

kitty77

Registered User.
Local time
Today, 09:16
Joined
May 27, 2019
Messages
693
Ok, when I send the email without

acSendReport, _
"BASS", _
acFormatPDF, _

It does not put the extra line.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 06:16
Joined
Oct 29, 2018
Messages
21,357
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

Top Bottom