设置使用VBA Outlook中的约会

问题描述 投票:0回答:1

我是一个初学者到编码,所以我想知道关于这个问题的帮助:我有一个excel表格中,用户将输入一个人的数据(姓名,电子邮件地址,手机号码,服务提供,预约日期,预约式,预约的时间)当按下一个按钮在Outlook中的电子邮件将自动起草以及预约既被发送到memeber。使用下面的代码,我不能拉承包商,客人的电子邮件地址或预约日期和时间形成的excel表到Outlook约会。

Sub Button2test_Click()
    Dim rng As Range
    Dim OutApp As Object
    Dim OutMail As Object

    Set rng = Nothing
     On Error Resume Next
    ' Only send the visible cells in the selection.
    Set rng = Selection.SpecialCells(xlCellTypeVisible)
    Set rng = 
    Sheets("Sheet1").RangeToHtml("D4:D12").SpecialCells(xlCellTypeVisible, 
    xlTextValues)
    On Error GoTo 0

    If rng Is Nothing Then
    MsgBox "The selection is not a range or the sheet is protected. " & _
           vbNewLine & "Please correct and try again.", vbOKOnly
    Exit Sub
    End If

    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
    .To = Range("$F$2")
    .CC = Range("$B$2")
    .BCC = ""
    .Subject = "Upcoming Scheduled Appointment"
    .HTMLBody = Range("$K$2")
    ' In place of the following statement, you can use ".Display" to
    ' display the e-mail message.
    .Display
    End With
    On Error GoTo 0

    With Application
    .EnableEvents = True
    .ScreenUpdating = True
     End With

     Set OutMail = Nothing
     Set OutApp = Nothing


    Set rng = Nothing
    On Error Resume Next
    ' Only send the visible cells in the selection.
    Set rng = Selection.SpecialCells(xlCellTypeVisible)
    Set rng = 
    Sheets("Sheet1").RangeToHtml("D4:D12").SpecialCells(xlCellTypeVisible, 
     xlTextValues)
    On Error GoTo 0

    If rng Is Nothing Then
    MsgBox "The selection is not a range or the sheet is protected. " & _
           vbNewLine & "Please correct and try again.", vbOKOnly
    Exit Sub
    End If

    With Application
    .EnableEvents = False
    .ScreenUpdating = False
    End With

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(olAppointmentItem)
    OutMail.MeetingStatus = olMeeting

    On Error Resume Next
    With OutMail
    .To = Range("$F$2")
    .Subject = Range("I2")
    .Location = Range("I2")
    .Importance = True
    .Start = Range("J2") & Format(Date + "H2")
    .End = Range("J2") & Format(Time + 0)
    .ReminderMinutesBeforeStart = 30
    .Body = Range("K2")
    .Display
    End With


    With Application
    .EnableEvents = True
    .ScreenUpdating = True
    End With

   Set OutMail = Nothing
   Set OutApp = Nothing
End Sub
excel vba outlook-vba appointment
1个回答
0
投票

这是非常困难的猜测你的代码是试图做。这里有几点让你开始。

这样使用On Error Resume Next的意思是“不打扰告诉我任何错误,因为我喜欢神秘的失败。就目前而言,只是删除所有On Error语句。

有些代码的地址明确的细胞:D4:D12,F2,B2,K2和I2。其他代码解决了选择中可见单元格。混合两种技术解决细胞是没有意义的我。

你必须Set rng = NothingSet OutApp = Nothing那么你有相同的代码块再次而是补充。你需要决定你想要的代码块。

你觉得这种说法确实:

Set rng = 
Sheets("Sheet1").RangeToHtml("D4:D12").SpecialCells(xlCellTypeVisible, 
xlTextValues)

除非是在线路末端的下划线要继续你不能传播的声明了几行。即使是语法正确的,我不知道这种说法是怎么有关宏的其余部分。

是细胞K2真是一个HTML的身体吗?我怀疑这是一个文本正文。

我在几年前退休了,所以我约会的记忆已经渐渐淡去。我的回忆是我们发出了邀请,并接收他们变成约会,接受他们。即使这些是正规团队会议,或类似的,你需要的与会者接受或因为你想知道谁将会来拒绝邀请。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.