none
display mail and save it in the draft folder ? RRS feed

  • Question

  •  

    i have this code , i want to display it and save it in the draft folde without opening the filedialog for the attachments again ... is that possible ?

    With OutMail


            .SentOnBehalfOfName = "xxx.be"
            .To = eMailStr
            .subject = subjectLine
            .CC = cop
            .BCC = copb
            .Body = bodyStr

                If f.Show = True Then
                    If f.SelectedItems(1) <> vbNullString Then
                        For i = 1 To f.SelectedItems.Count
                            bestand = bestand & f & "; "
            .Attachments.Add (f.SelectedItems(i))
                        Next i
                    End If
                Else
                End If

            .Save

        End With

                                          
    Sunday, March 20, 2016 9:35 AM

Answers

  • This code works:

    Option Explicit Const olMailItem = 0 Sub SaveTest() Dim Outmail As Object Dim MAPISession As Object Dim MAPIMailItem As Object On Error Resume Next Set Outmail = GetObject(, "Outlook.Application") 'Error if Outlook not running On Error GoTo 0 If Outmail Is Nothing Then 'Outlook not running so start it Set Outmail = CreateObject("Outlook.Application") End If Set MAPISession = Outmail.Application.Session 'Get the MAPI Outlook session If MAPISession Is Nothing Then MsgBox "Error creating Outlook session" Exit Sub End If MAPISession.Logon , , True, False 'Connect to the Outlook session Set MAPIMailItem = Outmail.CreateItem(olMailItem) 'Create a new mail message With MAPIMailItem .SentOnBehalfOfName = "noone@xxx.be" .To = "charles@hotmeil.com" .CC = "" .BCC = "" .Subject = "test" .Body = "Hello world"
    .Display .Save End With End Sub



    Best regards George

    Sunday, March 20, 2016 3:15 PM
  • Happy to help. It will always be saved to root of Draft folder.

    Please mark as answer.


    Best regards George

    • Marked as answer by tekoko10 Monday, March 21, 2016 6:17 AM
    Monday, March 21, 2016 5:55 AM

All replies

  • Yes, just add .Display Before .Save

    Best regards George

    Sunday, March 20, 2016 11:35 AM
  •    i've tried that before , but the mail doesn't com to the draft folder, i get 2 mails in the inbox this way
      
      With OutMail
           
           
            .SentOnBehalfOfName = "info@carpediemnv.be"
            .To = eMailStr
            .subject = subjectLine
            .CC = cop
            .BCC = copb
            .Body = bodyStr
            
                If f.Show = True Then
                    If f.SelectedItems(1) <> vbNullString Then
                        For i = 1 To f.SelectedItems.Count
                            bestand = bestand & f & "; "
            .Attachments.Add (f.SelectedItems(i))
                        Next i
                    End If
                Else
                End If
            
            .display
            .Save
           
        End With
       
    Sunday, March 20, 2016 2:05 PM
  • This code works:

    Option Explicit Const olMailItem = 0 Sub SaveTest() Dim Outmail As Object Dim MAPISession As Object Dim MAPIMailItem As Object On Error Resume Next Set Outmail = GetObject(, "Outlook.Application") 'Error if Outlook not running On Error GoTo 0 If Outmail Is Nothing Then 'Outlook not running so start it Set Outmail = CreateObject("Outlook.Application") End If Set MAPISession = Outmail.Application.Session 'Get the MAPI Outlook session If MAPISession Is Nothing Then MsgBox "Error creating Outlook session" Exit Sub End If MAPISession.Logon , , True, False 'Connect to the Outlook session Set MAPIMailItem = Outmail.CreateItem(olMailItem) 'Create a new mail message With MAPIMailItem .SentOnBehalfOfName = "noone@xxx.be" .To = "charles@hotmeil.com" .CC = "" .BCC = "" .Subject = "test" .Body = "Hello world"
    .Display .Save End With End Sub



    Best regards George

    Sunday, March 20, 2016 3:15 PM
  • it works, thanks ! 

    so with   .save  it Always come in the draft folder , or can one change it to a subfolder of the draft folder ?

    Monday, March 21, 2016 5:43 AM
  • Happy to help. It will always be saved to root of Draft folder.

    Please mark as answer.


    Best regards George

    • Marked as answer by tekoko10 Monday, March 21, 2016 6:17 AM
    Monday, March 21, 2016 5:55 AM