Results 1 to 6 of 6

Thread: sending outlook using access vba

  1. #1

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    sending outlook using access vba

    I'm tryng to send a form using access vba.

    i have an outlook form put value on fields that comes from my database then send the form.

    the problem is when i received the email..the form fields/controls has no value.

    here's my sample code.have just put some string on it not the actual records.

    VB Code:
    1. Sub Transfer_ToMail()
    2.     Dim oApp As Outlook.Application
    3.     Dim oMsg As Outlook.MailItem
    4.    
    5.     Dim oInspector As Outlook.Inspector
    6.     Dim oPages As Outlook.Pages
    7.     Dim oPage As Object
    8.     Dim oControls As Object
    9.     Dim oControl As Object
    10.    
    11.     Set oApp = New Outlook.Application
    12.     Set oMsg = oApp.CreateItemFromTemplate("C:\Template\FORM_TEMP.oft")
    13.     If Not oMsg Is Nothing Then
    14.         Set oInspector = oMsg.GetInspector
    15.         Set oPages = oInspector.ModifiedFormPages
    16.         Set oPage = oPages("Email Notification")
    17.         Set oControls = oPage.Controls
    18.        
    19.         Set oControl = oControls("FIELDNAME1")
    20.         oControl.Value = "AAA-AA"
    21.        
    22.         Set oControl = oControls("FIELDNAME2")
    23.         oControl.Value = "COMPANY"
    24.        
    25.         'oMsg.Display vbModal
    26.         oMsg.To = "Gates, Bill
    27.         oMsg.Send
    28.        
    29.     Else
    30.         MsgBox "Couldnt find your template!"
    31.     End If
    32.    
    33.    
    34.     Set Inspector = Nothing
    35.     Set Pages = Nothing
    36.     Set Page = Nothing
    37.     Set Controls = Nothing
    38.     Set Control = Nothing
    39.        
    40.     Set oMsg = Nothing
    41.     oApp.Quit
    42.     Set oApp = Nothing
    43. End Sub

    If a post has helped you then Please Rate it!

  2. #2

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Re: sending outlook using access vba

    would it matter if i design the controls with readonly properties? but when i tested this function and display the form the controls has the value i have programmtically entered. but when i send it to my self it return empty values on controls.

    why did i select readonly on properties? because i wanted it to be uneditable when the receiver clicked the forward mail function.

    If a post has helped you then Please Rate it!

  3. #3

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Re: sending outlook using access vba

    ok the problem occur because i have checked the readonly properties of controls..when i unchecked readonly from these controls then run my code it works fine.

    but then again i did not solved the real issue which is the form should not be editable when email forwarding.

    If a post has helped you then Please Rate it!

  4. #4

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Re: sending outlook using access vba

    ok heres another question..if i make a script that would handle event when the receiver hit the forward button..is this script would be available to the recepient when i send the form? is the script attached/connected with the form i've sent?

    If a post has helped you then Please Rate it!

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    Re: sending outlook using access vba

    If you're just sending a form, you could use DoCmd.SendObject acForm, "frmFoo", .... although you won't have as many options as when programming Outlook.
    Tengo mas preguntas que contestas

  6. #6

    Thread Starter
    Fanatic Member VBKNIGHT's Avatar
    Join Date
    Oct 2000
    Location
    Port25
    Posts
    619

    Re: sending outlook using access vba

    my concern truly is with the outlook form that i've sent..i want it to be uneditable when the user i've sent the mail try to forward it.

    If a post has helped you then Please Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width