Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Creating a Calendar Entry vbscript

Options
  • 24-05-2006 10:42am
    #1
    Closed Accounts Posts: 17


    Hi,

    I am having difficulty creating a meeting request from my company's intranet website. I can send mail using;
    Dim objMail As New Mail.MailMessage()

    'objMail.To = "someone@domain.com"
    objMail.To = cblStaff.SelectedItem.Value

    objMail.Cc = txtEmail.Text

    objMail.From = "someone@domain.com"
    'objMail.From = txtEmail.Text
    objMail.BodyFormat = Mail.MailFormat.Text
    objMail.Priority = Mail.MailPriority.High
    objMail.Subject = "Test ASP.NET email"
    objMail.Body = "Booking Update: Please check attached file "

    'the fields attribute was enabled by MS in .NET 1.1
    objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 2)

    '*****need to increment the file name*****
    'cf(above)
    Dim MyAttach As New Mail.MailAttachment("C:\sample1.dot")
    objMail.Attachments.Add(MyAttach)

    Mail.SmtpMail.SmtpServer = "example.exchange.com"

    Mail.SmtpMail.Send(objMail)
    I have searched forum after forum but I keep getting details from VS 2003 using CDO and MS Outlook 11.0 Object library.
    I have tried a piece of code using iCalendar but nothing happens when the submit Button event occurs (besides what is working already!)
    Private Sub Page_Load(sender As Object, e As System.EventArgs)
    Response.ContentType = "text/Calendar"

    Dim ical As iCalendar = GenerateCalendar()
    ical.WriteToStream(Response.OutputStream)
    Response.End() 'make sure nothing else gets written
    End Sub 'Page_Load


    Private Function GenerateCalendar() As iCalendar
    'use this method to create your calendar
    Dim ical As New iCalendar()
    ical.Event.Organizer.FullName = "Someone"
    ical.Event.Organizer.Email = "Someone@domain.com"
    ical.Event.DateStart.Date = New DateTime(2005, 1, 1)
    ical.Event.DateEnd.Date = New DateTime(2005, 1, 2)
    ical.Event.Description.Text = "New Years Holiday."

    Return ical
    End Function 'GenerateCalendar


    Any help would be greatly appreciated!

    Thanks


Comments

  • Closed Accounts Posts: 17 EthanCleary


    I managed to pull 4 or 5 snippets together to give me this which kinda works..

    Dim objOExp As Microsoft.Office.Interop.Outlook.Application
    Dim objAppt As Microsoft.Office.Interop.Outlook.AppointmentItem
    Const olAppointmentItem = 1
    Const olMeeting = 1

    Dim StartDate As DateTime = DateTime.Parse(txtBdate.Text)
    Dim EndDate As DateTime = DateTime.Parse(txtEdate.Text)

    Dim StartTime As DateTime = DateTime.Parse(txtBtime.Text)
    Dim EndTime As DateTime = DateTime.Parse(txtEtime.Text)

    objOExp = CreateObject("Outlook.Application")
    objAppt = objOExp.CreateItem(olAppointmentItem)
    With objAppt
    .Subject = objMail.Subject
    .Start = StartDate
    .End = EndDate


    ' make it a meeting request
    .MeetingStatus = olMeeting
    .RequiredAttendees = cblStaff.SelectedValue
    .RequiredAttendees = txtEmail.Text
    .Send()
    End With

    objAppt = Nothing
    objOExp = Nothing
    This allows me to send a meeting request to 'RequiredAttendess' for the correct date, but there is no attribute for the Time. This is probably due to me using ...

    txtBdate.Text = Calendar1.SelectedDate.ToShortDateString()

    ...which allows only the Date not DateTime to appear in my text box!

    Any takers on how enable my start & end time txtBoxes to be entered in the Outlook.AppointmentItem?

    Thanks


  • Registered Users Posts: 683 ✭✭✭Gosh


    I think the following will work
    .Start = StartDate + StartTime
    .End = EndDate + EndTime
    


  • Closed Accounts Posts: 17 EthanCleary


    Thanks for that Gosh but I now get this error..

    Conversion from string "5/26/20065/24/2006 9:00:00 AM" to type 'Date' is not valid

    Any more suggestions


  • Registered Users Posts: 683 ✭✭✭Gosh


    Which statement is giving the error, "5/26/20065/24/2006 9:00:00 AM" is obviously 2 dates together plus a time


  • Closed Accounts Posts: 17 EthanCleary


    All that was missing was a space between date and time fields...

    With objAppt
    .Subject = objMail.Subject
    .Start = StartDate + " " + txtBtime.Text
    .End = EndDate + " " + txtEtime.Text

    .Location = ddlLocation.SelectedValue
    .Subject = "Discussing the Agenda"
    .Body = "Let's get together to discuss the " _
    & "agenda."

    Thanks for the help Gosh!


  • Advertisement
Advertisement