Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using outlook form fields in email

Status
Not open for further replies.

itsmythg

Technical User
Apr 4, 2001
34
0
0
US
ok i have stolen enought code to get to the place i can create an email with a custome message but i am stuck at trying to add some information from some of the fields in my database. I need to add the data in field called networkid and others.

Private Sub Command20_Click()

Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.BodyFormat = olFormatRichText
.To = Me.Email_Address
.Subject = Me.Mess_Subject
.HTMLBody = "<HTML><BODY>"
"<p><b><font color=red><font size=6>Please READ all " & _
"custom message
"</BODY></HTML>"

If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.Add (Me.Mail_Attachment_Path)
End If
'.DeleteAfterSubmit = False 'This would let Outlook send th note without storing it in your sent bin
.Display
'.send
End With
'MsgBox MailOutLook.Body
'Exit Function
'email_error:
'MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
'Resume Error_out
Error_out:
'End Function
End Sub

Thanks Roxanne
 
Code:
Private Sub Command20_Click()

    Dim mess_body As String
    Dim appOutLook As Outlook.Application
    Dim MailOutLook As Outlook.MailItem
    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)

    Set appOutLook = CreateObject("Outlook.Application")
    Set MailOutLook = appOutLook.CreateItem(olMailItem)
[COLOR=red]
    Dim CustomMessage1 As String
    Dim CustomMessage2 As String

    CustomMessage1 = "This is the first line of message"
    CustomMessage2 = "This is the Second line of message"
[/color]
    With MailOutLook
        .BodyFormat = olFormatRichText
        .To = Me.Email_Address
        .Subject = Me.Mess_Subject
     [COLOR=red]   .HTMLBody = "<HTML><BODY>" _
                    & "<p><b><font color=red><font size=6>Please READ all</font></b></p>" _
                    & "<br>" & "<font color=black>" & CustomMessage1 & "</font>" _
                    & "<br>" & "<font color=green>" & CustomMessage2 & "</font>" _
                    & "</BODY></HTML>"[/color]

        If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
            .Attachments.Add (Me.Mail_Attachment_Path)
        End If
        '.DeleteAfterSubmit = False 'This would let Outlook send th note without storing it in your sent bin
        .display
        '.send
    End With
    'MsgBox MailOutLook.Body
    'Exit Function
    'email_error:
    'MsgBox "An error was encountered." & vbCrLf & "The error message is: " & Err.Description
    'Resume Error_out
Error_out:
    'End Function
End Sub


Zameer Abdulla
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top