Consulting

Results 1 to 13 of 13

Thread: Outlook 2007 E-Mail From Selected Task

  1. #1
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location

    Outlook 2007 E-Mail From Selected Task

    I have the following code that when I select one or more Tasks, it creates an email based on an email template to each contact that is the contact I created the Task to.....but, in the email, it shows up on the To bar, the name of the contact and not the full email address...and when I click on the name, it shows a list of the email and the tax number..and sometimes a phone number, and I have click on the email...so is there a way to have this code just go to and show the email, not anything else...thanks much:

    Public Sub Task_Email ()Dim Session As outlook.NameSpace
    Dim currentExplorer As Explorer
    Dim Selection As Selection
    
    
    Dim obj As Object
    
    
    Dim objMsg As MailItem
    
    
    Set currentExplorer = Application.ActiveExplorer
    Set Selection = currentExplorer.Selection
    
    
    On Error Resume Next
    
    
    For Each obj In Selection
    
    
    If obj.Class = olTask Then
    Set objTask = obj
    
    
    Set objMsg = Application.CreateItemFromTemplate("C:\UsersUserName\AppData\Roaming\Microsoft\Templates\emailform1.oft")
     
    Set toTask = objTask.Links(1)
    With objMsg
    .To = toTask.Item
    .Subject = "From Name"
    
    
    .Display
    End With
    
    
    Set objMsg = Nothing
    End If
    
    
    Err.Clear
    Next
    
    
    Set Session = Nothing
    Set currentExplorer = Nothing
    Set obj = Nothing
    Set Selection = Nothing
    
    
    End Sub

  2. #2
    try like
                With objMsg
                    .To = totask.Item.Email1Address

  3. #3
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Thanks so much. It worked perfectly!! I appreciate your help.

    In about an hour or two I will post another code that when I select a contact or more than one contact, it changes the words in certain user defined fields I created in the contact form...so the question will be what to change so I select the task(s) and it goes to the contact fields and makes the changes....that would be great for you help. Thanks very very much again.

  4. #4
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Here is the code of a UserForm that when I select one or more contacts, I run this Userform, it open up the drop list of dates and I select what date to add to the user defined field named "Status Date" of the contacts and it changes a specific field named "Status Date"in the contact.I can also add more fields with there names as an additional case to use....so is there a way to add to this or adjust it, so i recognizes the fields of the contacts that come from the objTask.Links(1) of each task, and then makes the changes to those contacts? Thanks very very much:

    Private Sub btnRun_Click()
        Dim Field As String
        Dim value As String
        Field = Me.ddlFields.Text
        value = Me.ddlValues.Text
        
       
            UpdateContactField Field, value
           
        Me.Hide
        
    End Sub
    
    
    Private Sub ddlFields_Change()
    
    
        Dim fld As String
        fld = Me.ddlFields.Text
        'Add your field related values here.
        
        Select Case fld
    
    
           
        Case "Status Date"
       
    
    
    Me.ddlValues.addItem "Jan-01-2014"
    Me.ddlValues.addItem "Jan-02-2014"
    Me.ddlValues.addItem "Jan-03-2014"
    Me.ddlValues.addItem "Jan-04-2014"
    Me.ddlValues.addItem "Jan-05-2014"
    Me.ddlValues.addItem "Jan-06-2014"
    Me.ddlValues.addItem "Jan-07-2014"
    Me.ddlValues.addItem "Jan-08-2014"
    Me.ddlValues.addItem "Jan-09-2014"
    Me.ddlValues.addItem "Jan-10-2014"
    Me.ddlValues.addItem "Jan-11-2014"
    Me.ddlValues.addItem "Jan-12-2014"
    Me.ddlValues.addItem "Jan-13-2014"
    Me.ddlValues.addItem "Jan-14-2014"
    Me.ddlValues.addItem "Jan-15-2014"
    Me.ddlValues.addItem "Jan-16-2014"
    Me.ddlValues.addItem "Jan-17-2014"
    Me.ddlValues.addItem "Jan-18-2014"
    Me.ddlValues.addItem "Jan-19-2014"
    Me.ddlValues.addItem "Jan-20-2014"
    Me.ddlValues.addItem "Jan-21-2014"
    Me.ddlValues.addItem "Jan-22-2014"
    Me.ddlValues.addItem "Jan-23-2014"
    Me.ddlValues.addItem "Jan-24-2014"
    Me.ddlValues.addItem "Jan-25-2014"
    Me.ddlValues.addItem "Jan-26-2014"
    Me.ddlValues.addItem "Jan-27-2014"
    Me.ddlValues.addItem "Jan-28-2014"
    Me.ddlValues.addItem "Jan-29-2014"
    Me.ddlValues.addItem "Jan-30-2014"
    
    
    
    
    Private Sub UserForm_Initialize()
        'Add your field names here.
        
        Me.ddlFields.addItem "Status Date"
                
    End Sub

  5. #5
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Any possible update....that would be great....thanks much

  6. #6
    afaik you can not return the contacts that are selected, possibly if you add all the contacts in the task to a multi select list box on the userform, then select them there

    here is somthing you can try, to avoid retyping the dates every month
    Case "Status Date"
       For i = 1 To Day(DateSerial(Year(Now), Month(Now) + 1, 1) - 1)
        me.ddlvalues.additem Format(DateSerial(Year(Now), Month(Now), i), "mmm-dd-yyyy")
       Next
    Last edited by westconn1; 01-25-2014 at 03:34 AM.

  7. #7
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    I did what you gave me re the Status Date, and it worked perfectly......is there a way to show the current month and the next 3 months or 4 months, as sometimes my dates are later? Thanks very much.


    Since in the earlier post, you showed me how to refer to the email address. So can there be a code line where a field for each task contact equals a certain the Case, so whatever words I select from the Case droplist, it goes to the certain field of each Contact?
    Last edited by lms; 01-25-2014 at 09:44 AM.

  8. #8
    try like
    Case "Status Date" 
      for m = 1 to 4
        For i = 1 To Day(DateSerial(Year(Now), Month(Now) + m, 1) - 1) 
            me.ddlvalues.additem Format(DateSerial(Year(Now), Month(Now)+ m -1, i), "mmm-dd-yyyy") 
        Next 
      next

  9. #9
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Again, thanks so much as it worked great again.........so on the date side, since there is also a field in the contact re the time no just the date......and here is the the list I use.....can we do something like your date code so it is much easier to create the code for the time of the date:

    Me.ddlValues.addItem "12:00 AM"
    Me.ddlValues.addItem "12:30 AM"
    Me.ddlValues.addItem "1:00 AM"
    Me.ddlValues.addItem "1:30 AM"
    Me.ddlValues.addItem "2:00 AM"
    Me.ddlValues.addItem "2:30 AM"
    Me.ddlValues.addItem "3:00 AM"
    Me.ddlValues.addItem "3:30 AM"
    Me.ddlValues.addItem "4:00 AM"
    Me.ddlValues.addItem "4:30 AM"
    Me.ddlValues.addItem "5:00 AM"
    Me.ddlValues.addItem "5:30 AM"
    Me.ddlValues.addItem "6:00 AM"
    Me.ddlValues.addItem "6:30 AM"
    Me.ddlValues.addItem "7:00 AM"
    Me.ddlValues.addItem "7:30 AM"
    Me.ddlValues.addItem "8:00 AM"
    Me.ddlValues.addItem "8:30 AM"
    Me.ddlValues.addItem "9:00 AM"
    Me.ddlValues.addItem "9:30 AM"
    Me.ddlValues.addItem "10:00 AM"
    Me.ddlValues.addItem "10:30 AM"
    Me.ddlValues.addItem "11:00 AM"
    Me.ddlValues.addItem "11:30 AM"
    Me.ddlValues.addItem "12:00 PM"
    Me.ddlValues.addItem "12:30 PM"
    Me.ddlValues.addItem "1:00 PM"
    Me.ddlValues.addItem "1:30 PM"
    Me.ddlValues.addItem "2:00 PM"
    Me.ddlValues.addItem "2:30 PM"
    Me.ddlValues.addItem "3:00 PM"
    Me.ddlValues.addItem "3:30 PM"
    Me.ddlValues.addItem "4:00 PM"
    Me.ddlValues.addItem "4:30 PM"
    Me.ddlValues.addItem "5:00 PM"
    Me.ddlValues.addItem "5:30 PM"
    Me.ddlValues.addItem "6:00 PM"
    Me.ddlValues.addItem "6:30 PM"
    Me.ddlValues.addItem "7:00 PM"
    Me.ddlValues.addItem "7:30 PM"
    Me.ddlValues.addItem "8:00 PM"
    Me.ddlValues.addItem "8:30 PM"
    Me.ddlValues.addItem "9:00 PM"
    Me.ddlValues.addItem "9:30 PM"
    Me.ddlValues.addItem "10:00 PM"
    Me.ddlValues.addItem "10:30 PM"
    Me.ddlValues.addItem "11:00 PM"
    Me.ddlValues.addItem "11:30 PM"

  10. #10
    try like
    For t = 0 To 23.5 Step 0.5
        Me.ddlValues.addItem Format(TimeSerial(Int(t), (t - Int(t)) * 60, 0), "medium time")
    Next

  11. #11
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Great...I did it...and it works perfectly...thanks so much.....and I changed it so it shows the times every 15 minutes...but also, before a time that is not two numbers...like 1:00am.....is shows up 01:OOam....so can we change it so it is not showing the O before the real time?

    For t = 0 To 23.75 Step 0.25
    Me.ddlValues.addItem Format(TimeSerial(Int(t), (t - Int(t)) * 60, 0), "medium time")
    Next

  12. #12
    so it is not showing the O before the real time?
    you would have to use a custom format

    try
    replace "medium time" with "h:nn AM/PM"

  13. #13
    VBAX Regular
    Joined
    Jul 2013
    Posts
    75
    Location
    Once again, I so appreciate your help....it worked perfectly.....I get an e-mail each time you respond.....and if you would like to talk on the phone, happy to meet you over the phone....and I can explain those areas easily and you might have a quick answer...and also, if it does not makes sense to talk on the phone as to the policies of this forum, I totally respect that as well.....thanks so much

Posting Permissions

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