panuvin
Mar 9th, 2005, 02:54 PM
Hello,
I'm a relatively new VB programmer and am having trouble with an outlook form. Whenever I click on CommandButton2, it will only send an email with MS Outlook 2000. My colleagues are using Outlook v2002 (SP3) and clicking the button does nothing. Has anyone ever heard of this happening? Maybe one of you pros can help me out =)
Any feedback would be greatly appreciated!
Here's the code:
Sub CommandButton2_Click()
Item.cc = Item.userproperties.find("managername").value & ";" & Item.userproperties.find("employeename").value
If Item.userproperties.find("ScorecardChecked").value = True Then ' require checkbox marked
Item.Save ' save current settings
Set AssignedFolder = Application.GetNameSpace("MAPI").GetDefaultFolder(6)
Set NewItem = AssignedFolder.Items.Add("IPM.Note.Staff Dialogue Routing Form")
NewItem.UserProperties.Find("Employee ID number").value = item.UserProperties.Find("Employee ID number").value
NewItem.UserProperties.Find("Manager Comments").value = item.UserProperties.Find("Manager Comments").value
NewItem.UserProperties.Find("managername").value = item.UserProperties.Find("managername").value
NewItem.UserProperties.Find("ScorecardChecked").value = item.UserProperties.Find("ScorecardChecked").value
NewItem.UserProperties.Find("Employee Comments").value = item.UserProperties.Find("Employee Comments").value
NewItem.UserProperties.Find("employeename").value = item.UserProperties.Find("employeename").value
NewItem.UserProperties.Find("lvl2Mgr").value = item.UserProperties.Find("lvl2Mgr").value
NewItem.UserProperties.Find("HRBusinessPartner").value = item.UserProperties.Find("HRBusinessPartner").value
NewItem.Body = item.body
NewItem.cc = item.cc
AlsoSendto = item.cc
' Now, let's deal with copying the attachments from the existing form to the new form ;)
set saveAttachments = Item.Attachments
set NewAttachments = Newitem.attachments
set fso = CreateObject("Scripting.FileSystemObject")
sDirSpec = "c:\ngwm" & item.UserProperties.Find("Employee ID number").value
fso.CreateFolder (sDirSpec)
if saveAttachments.count > 0 then ' The files must be saved in order to be forwarded
for i =1 to saveAttachments.count
sFileSpec = saveattachments.item(i).displayname
saveattachments.item(i).saveasfile sDirSpec & "\" & sFileSpec
Newattachments.add sDirSpec & "\" & sFileSpec
next
end if
fso.DeleteFolder (sDirSpec)
NewItem.To = AlsoSendto & "; Employee Resource Center; " & Item.UserProperties.Find("lvl2Mgr").value & ";" & mid(Item.userproperties.find("HRBusinessPartner").value,inStr(1,Item.userproperties.find("HRBusinessPartner").value," - ")+3)
NewItem.send
Item.Delete ' delete current message opened
Else
MsgBox "blah"
End If
End Sub
I'm a relatively new VB programmer and am having trouble with an outlook form. Whenever I click on CommandButton2, it will only send an email with MS Outlook 2000. My colleagues are using Outlook v2002 (SP3) and clicking the button does nothing. Has anyone ever heard of this happening? Maybe one of you pros can help me out =)
Any feedback would be greatly appreciated!
Here's the code:
Sub CommandButton2_Click()
Item.cc = Item.userproperties.find("managername").value & ";" & Item.userproperties.find("employeename").value
If Item.userproperties.find("ScorecardChecked").value = True Then ' require checkbox marked
Item.Save ' save current settings
Set AssignedFolder = Application.GetNameSpace("MAPI").GetDefaultFolder(6)
Set NewItem = AssignedFolder.Items.Add("IPM.Note.Staff Dialogue Routing Form")
NewItem.UserProperties.Find("Employee ID number").value = item.UserProperties.Find("Employee ID number").value
NewItem.UserProperties.Find("Manager Comments").value = item.UserProperties.Find("Manager Comments").value
NewItem.UserProperties.Find("managername").value = item.UserProperties.Find("managername").value
NewItem.UserProperties.Find("ScorecardChecked").value = item.UserProperties.Find("ScorecardChecked").value
NewItem.UserProperties.Find("Employee Comments").value = item.UserProperties.Find("Employee Comments").value
NewItem.UserProperties.Find("employeename").value = item.UserProperties.Find("employeename").value
NewItem.UserProperties.Find("lvl2Mgr").value = item.UserProperties.Find("lvl2Mgr").value
NewItem.UserProperties.Find("HRBusinessPartner").value = item.UserProperties.Find("HRBusinessPartner").value
NewItem.Body = item.body
NewItem.cc = item.cc
AlsoSendto = item.cc
' Now, let's deal with copying the attachments from the existing form to the new form ;)
set saveAttachments = Item.Attachments
set NewAttachments = Newitem.attachments
set fso = CreateObject("Scripting.FileSystemObject")
sDirSpec = "c:\ngwm" & item.UserProperties.Find("Employee ID number").value
fso.CreateFolder (sDirSpec)
if saveAttachments.count > 0 then ' The files must be saved in order to be forwarded
for i =1 to saveAttachments.count
sFileSpec = saveattachments.item(i).displayname
saveattachments.item(i).saveasfile sDirSpec & "\" & sFileSpec
Newattachments.add sDirSpec & "\" & sFileSpec
next
end if
fso.DeleteFolder (sDirSpec)
NewItem.To = AlsoSendto & "; Employee Resource Center; " & Item.UserProperties.Find("lvl2Mgr").value & ";" & mid(Item.userproperties.find("HRBusinessPartner").value,inStr(1,Item.userproperties.find("HRBusinessPartner").value," - ")+3)
NewItem.send
Item.Delete ' delete current message opened
Else
MsgBox "blah"
End If
End Sub