Results 1 to 6 of 6
  1. #1
    onlylonely is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2017
    Posts
    110

    VBA sending email

    Hi Guy,

    Appreciate if your could give me some clue on how to write a email coding.
    Below is my coding.

    Code:
    Function Issued_Email()
    
    Dim oApp As Outlook.Application
    Dim oMail As MailItem
    Set oApp = CreateObject("Outlook.application")
    Dim mailbody As String
    
    
    Set oMail = oApp.CreateItem(olMailItem)
    oMail.Subject = "[e-CAR - Autogenerated] - "" & Forms!F1NCForm!txtscar & "" has been issued to you."
    
    
    oMail.Body = "Hi " & Forms!F1NCForm!cmbeid & "," & Chr(10) & Chr(10)
    oMail.Body = " <a href="" C:\Tony\Project\MS Access\Waters\Database4.accdb ""> Click me</a> "
    
    
    oMail.To = "a@abc.com"
    'oMail.CC =
    oMail.Send
    
    
    '.Display
    Set oMail = Nothing
    Set oApp = Nothing
    
    End function
    The issue i'm facing is oMail.Subject = "[e-CAR - Autogenerated] - " & Forms!F1NCForm!txtscar & " has been issued to you."


    The subject doesn't come out with what i'm expected.
    Subject expected : [e-CAR - Autogenerated] - SG002 has been issued to you.
    Subject outcome : [e-CAR - Autogenerated] - has been issued to you. <<< MISSING SG002

    oMail.Body = "Hi " & Forms!F1NCForm!cmbeid & "," & Chr(10) & Chr(10)
    body expected : Hi Kris,
    body outcome : Hi <<<< MISSING KRIS

    oMail.Body = " <a href="" C:\Tony\Project\MS Access\Waters\Database4.accdb ""> Click me</a> "
    body expected : Click me.
    Body outcome : empty

    Anyone have some clue for me to solve this issue?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Both the missing fields are supposed to be on form FINCForm. The form has to be open with the 2 fields containing the wanted data present.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    if you use html in the body, use:

    .HTMLBody = "<a href…..

  4. #4
    onlylonely is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2017
    Posts
    110
    Quote Originally Posted by davegri View Post
    Both the missing fields are supposed to be on form FINCForm. The form has to be open with the 2 fields containing the wanted data present.
    I have all those information at the form. But still not showing another in the email.

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,405
    Code:
    Function Issued_Email()
    
    
    Dim oApp As Outlook.Application
    Dim oMail As MailItem
    Set oApp = CreateObject("Outlook.application")
    Dim mailbody As String
    
    
    Msgbox "txtscar is " & Forms!F1NCForm!txtscar _
    & " And cmbeid is " & Forms!F1NCForm!cmbeid
    
    
    Set oMail = oApp.CreateItem(olMailItem)
    oMail.Subject = "[e-CAR - Autogenerated] - "" & Forms!F1NCForm!txtscar & "" has been issued to you."
    
    
    
    
    oMail.Body = "Hi " & Forms!F1NCForm!cmbeid & "," & Chr(10) & Chr(10)
    oMail.Body = " <a href="" C:\Tony\Project\MS Access\Waters\Database4.accdb ""> Click me</a> "
    
    
    
    
    oMail.To = "a@abc.com"
    'oMail.CC =
    oMail.Send
    
    
    
    
    '.Display
    Set oMail = Nothing
    Set oApp = Nothing
    
    
    End function
    You could add the red code, but it would probably show blanks.
    Are you sure you have the form name correct F-one-NCForm ?

  6. #6
    onlylonely is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    May 2017
    Posts
    110
    Quote Originally Posted by davegri View Post
    Code:
    Function Issued_Email()
    
    
    Dim oApp As Outlook.Application
    Dim oMail As MailItem
    Set oApp = CreateObject("Outlook.application")
    Dim mailbody As String
    
    
    Msgbox "txtscar is " & Forms!F1NCForm!txtscar _
    & " And cmbeid is " & Forms!F1NCForm!cmbeid
    
    
    Set oMail = oApp.CreateItem(olMailItem)
    oMail.Subject = "[e-CAR - Autogenerated] - "" & Forms!F1NCForm!txtscar & "" has been issued to you."
    
    
    
    
    oMail.Body = "Hi " & Forms!F1NCForm!cmbeid & "," & Chr(10) & Chr(10)
    oMail.Body = " <a href="" C:\Tony\Project\MS Access\Waters\Database4.accdb ""> Click me</a> "
    
    
    
    
    oMail.To = "a@abc.com"
    'oMail.CC =
    oMail.Send
    
    
    
    
    '.Display
    Set oMail = Nothing
    Set oApp = Nothing
    
    
    End function
    You could add the red code, but it would probably show blanks.
    Are you sure you have the form name correct F-one-NCForm ?
    Hi Dave,

    Thanks for your input, I've solved the issue. I'm putting wrong place for the "CALL EMAIL"

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

Similar Threads

  1. Replies: 1
    Last Post: 11-07-2016, 11:18 AM
  2. sending email from outlook
    By darwish in forum Programming
    Replies: 1
    Last Post: 04-16-2014, 07:49 AM
  3. Sending A Report Via Email
    By Ka-Tet in forum Reports
    Replies: 0
    Last Post: 09-02-2013, 09:18 AM
  4. Email sending
    By Steven.Allman in forum Access
    Replies: 25
    Last Post: 06-21-2010, 09:37 AM
  5. Sending email
    By nashr1928 in forum Reports
    Replies: 8
    Last Post: 04-27-2010, 11:14 PM

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